12.1 Iteration G1: Capturing an Order 11.4 Iteration F4: Hide an Empty Cart
Verify that yes, indeed, the product index is broken.
get /products
Showing /home/rubys/git/awdwr/edition4/work-192-30/depot/app/views/layouts/application.html.erb where line #21 raised:
undefined method `line_items' for nil:NilClass
Extracted source (around line #21):
18: <div id="side">
19: <!-- START_HIGHLIGHT -->
20: <!-- START:hidden_div -->
21: <%= hidden_div_if(@cart.line_items.empty?, id: 'cart') do %>
22: <%= render @cart %>
23: <% end %>
24: <!-- END:hidden_div -->
Rails.root: /home/rubys/git/awdwr/edition4/work-192-30/depot
app/views/layouts/application.html.erb:21:in `_app_views_layouts_application_html_erb__3170943767193227703_69993881821200__488913405935584186'
app/controllers/products_controller.rb:7:in `index'
/home/rubys/git/rails/activesupport/lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:135:in `block in render'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:54:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:127:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/render/layouts.rb:80:in `_render_layout'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:62:in `block in _render_template'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `block in instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:56:in `_render_template'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:26:in `render'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:115:in `_render_template'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:109:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/renderers.rb:47:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:102:in `render_to_string'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:93:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:17:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
/home/rubys/git/rails/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/home/rubys/git/rails/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
/home/rubys/git/rails/activerecord/lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:39:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/mime_responds.rb:261:in `block in retrieve_response_from_mimes'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/mime_responds.rb:192:in `call'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:150:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:11:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:436:in `_run__3948946555206880047__process_action__1814969014083062931__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:94:in `run_callbacks'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rescue.rb:17:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `block in instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:119:in `process'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:41:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/metal.rb:138:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_controller/metal.rb:178:in `block in action'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:68:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:68:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:33:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:499:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.8) lib/rack/methodoverride.rb:24:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/flash.rb:182:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/cookies.rb:302:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:32:in `block in call'
/home/rubys/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:12:in `cache'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:31:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.8) lib/rack/sendfile.rb:106:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:13:in `call'
rack (1.2.8) lib/rack/runtime.rb:17:in `call'
/home/rubys/git/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.8) lib/rack/lock.rb:13:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.8) lib/rack/lock.rb:13:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/static.rb:30:in `call'
/home/rubys/git/rails/railties/lib/rails/application.rb:168:in `call'
/home/rubys/git/rails/railties/lib/rails/application.rb:77:in `method_missing'
/home/rubys/git/rails/railties/lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.8) lib/rack/content_length.rb:13:in `call'
rack (1.2.8) lib/rack/handler/webrick.rb:52:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
/home/rubys/git/rails/activesupport/lib/active_support/whiny_nil.rb:48:in `method_missing'
app/views/layouts/application.html.erb:21:in `_app_views_layouts_application_html_erb__3170943767193227703_69993881821200__488913405935584186'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:135:in `block in render'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:54:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:127:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/render/layouts.rb:80:in `_render_layout'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:62:in `block in _render_template'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `block in instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:56:in `_render_template'
/home/rubys/git/rails/actionpack/lib/action_view/render/rendering.rb:26:in `render'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:115:in `_render_template'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:109:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/renderers.rb:47:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:102:in `render_to_string'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:93:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:17:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
/home/rubys/git/rails/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/home/rubys/git/rails/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
/home/rubys/git/rails/activerecord/lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:39:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/mime_responds.rb:261:in `block in retrieve_response_from_mimes'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/mime_responds.rb:192:in `call'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
app/controllers/products_controller.rb:7:in `index'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:150:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:11:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:436:in `_run__3948946555206880047__process_action__1814969014083062931__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:94:in `run_callbacks'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rescue.rb:17:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `block in instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:52:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:119:in `process'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:41:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/metal.rb:138:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_controller/metal.rb:178:in `block in action'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:68:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:68:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:33:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:499:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.8) lib/rack/methodoverride.rb:24:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/flash.rb:182:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/cookies.rb:302:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:32:in `block in call'
/home/rubys/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:12:in `cache'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:31:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.8) lib/rack/sendfile.rb:106:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:13:in `call'
rack (1.2.8) lib/rack/runtime.rb:17:in `call'
/home/rubys/git/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.8) lib/rack/lock.rb:13:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.8) lib/rack/lock.rb:13:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/static.rb:30:in `call'
/home/rubys/git/rails/railties/lib/rails/application.rb:168:in `call'
/home/rubys/git/rails/railties/lib/rails/application.rb:77:in `method_missing'
/home/rubys/git/rails/railties/lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.8) lib/rack/content_length.rb:13:in `call'
rack (1.2.8) lib/rack/handler/webrick.rb:52:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Parameters:
None
_csrf_token: "ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=" cart_id: 3 session_id: "bfc597470818e99e50061b581e4885b6"
GATEWAY_INTERFACE: "CGI/1.1" HTTP_ACCEPT: "text/html" HTTP_COOKIE: "_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly" HTTP_HOST: "localhost:3000" HTTP_USER_AGENT: "Ruby" HTTP_VERSION: "HTTP/1.1" PATH_INFO: "/products" QUERY_STRING: "" REMOTE_ADDR: "127.0.0.1" REMOTE_HOST: "localhost" REQUEST_METHOD: "GET" REQUEST_PATH: "/" REQUEST_URI: "http://localhost:3000/products" SCRIPT_NAME: "" SERVER_NAME: "localhost" SERVER_PORT: "3000" SERVER_PROTOCOL: "HTTP/1.1" SERVER_SOFTWARE: "WEBrick/1.3.1 (Ruby/1.9.2/2012-04-20)" action_controller.instance: #<ProductsController:0x007f5170fd2f00 @action_has_layout=true, @view_context_class=nil, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_response=#<ActionDispatch::Response:0x007f5170fd2d20 @writer=#<Proc:0x007f5170fd2c58@/home/rubys/git/rails/actionpack/lib/action_dispatch/http/response.rb:43 (lambda)>, @block=nil, @length=0, @header={}, @status=200, @body=[], @cookie=[], @sending_file=false, @blank=false, @cache_control={}, @etag=nil, @request=#<ActionDispatch::Request:0x007f5170fd2d48 @env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/products", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/products", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2012-04-20)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x0000000278b6d8>, "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "HTTP_VERSION"=>"HTTP/1.1", "REQUEST_PATH"=>"/", "action_dispatch.parameter_filter"=>[:password], "action_dispatch.secret_token"=>"c51086661c17b125348d82415b3c706b138e238eedbbf99205f8e2cf2ed6f59da3ea58c8b419d3431e9c4996b946c1deab67d42de2ad0913bc14864aceed4017", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"bfc597470818e99e50061b581e4885b6"}, "rack.request.cookie_string"=>"_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil}, "action_dispatch.cookies"=>{"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil}, "action_dispatch.request.unsigned_session_cookie"=>{"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3}, "action_dispatch.request.path_parameters"=>{:action=>"index", :controller=>"products"}, "action_controller.instance"=>#<ProductsController:0x007f5170fd2f00 ...>, "action_dispatch.request.content_type"=>nil, "action_dispatch.request.request_parameters"=>{}, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.request.parameters"=>{"action"=>"index", "controller"=>"products"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @request_method="GET", @filtered_parameters={"action"=>"index", "controller"=>"products"}, @method="GET", @fullpath="/products", @symbolized_path_params={:action=>"index", :controller=>"products"}>, @content_type="text/html">, @_request=#<ActionDispatch::Request:0x007f5170fd2d48 @env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/products", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/products", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2012-04-20)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x0000000278b6d8>, "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "HTTP_VERSION"=>"HTTP/1.1", "REQUEST_PATH"=>"/", "action_dispatch.parameter_filter"=>[:password], "action_dispatch.secret_token"=>"c51086661c17b125348d82415b3c706b138e238eedbbf99205f8e2cf2ed6f59da3ea58c8b419d3431e9c4996b946c1deab67d42de2ad0913bc14864aceed4017", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"bfc597470818e99e50061b581e4885b6"}, "rack.request.cookie_string"=>"_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil}, "action_dispatch.cookies"=>{"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil}, "action_dispatch.request.unsigned_session_cookie"=>{"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3}, "action_dispatch.request.path_parameters"=>{:action=>"index", :controller=>"products"}, "action_controller.instance"=>#<ProductsController:0x007f5170fd2f00 ...>, "action_dispatch.request.content_type"=>nil, "action_dispatch.request.request_parameters"=>{}, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.request.parameters"=>{"action"=>"index", "controller"=>"products"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @request_method="GET", @filtered_parameters={"action"=>"index", "controller"=>"products"}, @method="GET", @fullpath="/products", @symbolized_path_params={:action=>"index", :controller=>"products"}>, @_env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/products", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/products", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2012-04-20)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x0000000278b6d8>, "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "HTTP_VERSION"=>"HTTP/1.1", "REQUEST_PATH"=>"/", "action_dispatch.parameter_filter"=>[:password], "action_dispatch.secret_token"=>"c51086661c17b125348d82415b3c706b138e238eedbbf99205f8e2cf2ed6f59da3ea58c8b419d3431e9c4996b946c1deab67d42de2ad0913bc14864aceed4017", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"bfc597470818e99e50061b581e4885b6"}, "rack.request.cookie_string"=>"_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil}, "action_dispatch.cookies"=>{"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil}, "action_dispatch.request.unsigned_session_cookie"=>{"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3}, "action_dispatch.request.path_parameters"=>{:action=>"index", :controller=>"products"}, "action_controller.instance"=>#<ProductsController:0x007f5170fd2f00 ...>, "action_dispatch.request.content_type"=>nil, "action_dispatch.request.request_parameters"=>{}, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.request.parameters"=>{"action"=>"index", "controller"=>"products"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @lookup_context=#<ActionView::LookupContext:0x007f5170fd1fd8 @details_key=#<ActionView::LookupContext::DetailsKey:0x007f5170351880 @hash=524072319900793862>, @details={:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]}, @skip_default_locale=false, @frozen_formats=true, @view_paths=[/home/rubys/git/awdwr/edition4/work-192-30/depot/app/views]>, @_action_name="index", @_response_body=nil, @_config={}, @products=[#<Product id: 2, title: "CoffeeScript", description: "<p>\n CoffeeScript is JavaScript done right. ...", image_url: "/images/cs.jpg", price: #<BigDecimal:7f5170614e78,'0.36E2',9(18)>, created_at: "2014-02-04 20:40:52", updated_at: "2014-02-04 20:40:52">, #<Product id: 3, title: "Programming Ruby 1.9 & 2.0", description: "<p>\n Ruby is the fastest growing and most ex...", image_url: "/images/ruby.jpg", price: #<BigDecimal:7f51705f9d08,'0.4995E2',18(18)>, created_at: "2014-02-04 20:40:52", updated_at: "2014-02-04 20:40:52">, #<Product id: 4, title: "Rails Test Prescriptions", description: "<p>\n <em>Rails Test Prescriptions</em> is a ...", image_url: "/images/rtp.jpg", price: #<BigDecimal:7f51705e3be8,'0.3495E2',18(18)>, created_at: "2014-02-04 20:40:52", updated_at: "2014-02-04 20:40:52">]> action_dispatch.cookies: {"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil} action_dispatch.parameter_filter: [:password] action_dispatch.remote_ip: 127.0.0.1 action_dispatch.request.accepts: [text/html] action_dispatch.request.content_type: nil action_dispatch.request.formats: [text/html] action_dispatch.request.parameters: {"action"=>"index", "controller"=>"products"} action_dispatch.request.path_parameters: {:action=>"index", :controller=>"products"} action_dispatch.request.query_parameters: {} action_dispatch.request.request_parameters: {} action_dispatch.request.unsigned_session_cookie: {"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3} action_dispatch.secret_token: "c51086661c17b125348d82415b3c706b138e238eedbbf99205f8e2cf2ed6f59da3ea58c8b419d3431e9c4996b946c1deab67d42de2ad0913bc14864aceed4017" action_dispatch.show_exceptions: true rack.errors: #<IO:<STDERR>> rack.input: #<StringIO:0x0000000278b6d8> rack.multiprocess: false rack.multithread: false rack.request.cookie_hash: {"_depot_session"=>"BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199", "path"=>"/", "HttpOnly"=>nil} rack.request.cookie_string: "_depot_session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiIlYmZjNTk3NDcwODE4ZTk5ZTUwMDYxYjU4MWU0ODg1YjZJIhBfY3NyZl90b2tlbgY7AEZJIjFvY1l0V3NZQzRxeXlnaGNRR3g1eHgyTEZUenlTVGVKa3FPWDRleWFXLzhBPQY7AEZJIgxjYXJ0X2lkBjsARmkI--4786e8ca3e2f90a07c6311bb34a02db707599199; path=/; HttpOnly" rack.request.query_hash: {} rack.request.query_string: "" rack.run_once: false rack.session: {"session_id"=>"bfc597470818e99e50061b581e4885b6", "_csrf_token"=>"ocYtWsYC4qyyghcQGx5xx2LFTzySTeJkqOX4eyaW/8A=", "cart_id"=>3} rack.session.options: {:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"bfc597470818e99e50061b581e4885b6"} rack.url_scheme: "http" rack.version: [1, 1]
Headers:
None
Conditionally display the cart.
edit app/views/layouts/application.html.erb
<% if @cart %>
<%= hidden_div_if(@cart.line_items.empty?, id: 'cart') do %>
<%= render @cart %>
<% end %>
<% end %>
Update the redirect test.
edit test/functional/line_items_controller_test.rb
test "should create line_item" do
assert_difference('LineItem.count') do
post :create, :product_id => products(:ruby).id
end
assert_redirected_to store_path
end
Add an XHR test.
edit test/functional/line_items_controller_test.rb
test "should create line_item via ajax" do
assert_difference('LineItem.count') do
xhr :post, :create, :product_id => products(:ruby).id
end
assert_response :success
assert_select_rjs :replace_html, 'cart' do
assert_select 'tr#current_item td', /Programming Ruby 1.9/
end
end
Add an test in support for the coffeescript changes.
edit test/functional/store_controller_test.rb
test "markup needed for store.js.coffee is in place" do
get :index
assert_select '.store .entry > img', 3
assert_select '.entry input[type=submit]', 3
end
Run the tests again.
rake test
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/rake_test_loader
Started
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
........
Finished in 0.367365 seconds.
8 tests, 29 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 43918
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-p320/gems/rake-10.1.1/lib/rake/rake_test_loader
Started
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
.........................
Finished in 0.652994 seconds.
25 tests, 43 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 33531
Save our progress
git commit -a -m "AJAX"
[master 7d28282] AJAX
3 files changed, 42 insertions(+), 11 deletions(-)
git tag iteration-f
12.1 Iteration G1: Capturing an Order 11.4 Iteration F4: Hide an Empty Cart