Agile Web Development with Rails, Edition 4
Agile Web Development with Rails, Edition 4
12.1 Iteration G1: Capturing an Order
11.5 Iteration F5: Making Images Clickable
11.6 Iteration F6: Testing AJAX changes
Verify that yes, indeed, the product index is broken.
get /products
NoMethodError in
Products#index
Showing /home/rubys/git/awdwr/edition4/work-187/depot/app/views/layouts/application.html.erb where line #20 raised:
undefined method `line_items' for nil:NilClass
Extracted source (around line #20):
17: <div id="side">
18: <!-- START_HIGHLIGHT -->
19: <!-- START:hidden_div -->
20: <%= hidden_div_if(@cart.line_items.empty?, :id => 'cart') do %>
21: <%= render @cart %>
22: <% end %>
23: <!-- END:hidden_div -->
Rails.root: /home/rubys/git/awdwr/edition4/work-187/depot
Application Trace |
Framework Trace |
Full Trace
app/views/layouts/application.html.erb:20:in `_app_views_layouts_application_html_erb__1076610244_69891758384860'
app/controllers/products_controller.rb:7:in `index'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:145:in `send'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:145:in `render'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:125:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:143:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/template_renderer.rb:18:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/renderer.rb:36:in `render_template'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/renderer.rb:17:in `render'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:110:in `_render_template'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/streaming.rb:225:in `_render_template'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:103:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:88:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:16:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `render'
/home/rubys/git/rails/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/benchmark.rb:308: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 `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
/home/rubys/git/rails/activerecord/lib/active_record/railties/controller_runtime.rb:24: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:196: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/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:167:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:18:in `process_action'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:414:in `_run__1118320962__process_action__199225275__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81: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:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:123:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:123:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/home/rubys/git/rails/activerecord/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:121:in `process'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:45:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/metal.rb:203: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:246:in `action'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:73:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:36:in `call'
/home/rubys/git/journey/lib/journey/router.rb:68:in `call'
/home/rubys/git/journey/lib/journey/router.rb:56:in `each'
/home/rubys/git/journey/lib/journey/router.rb:56:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:600:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/head.rb:14: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:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:64:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:28:in `call'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `_run__397314981__call__4__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:32:in `call_app'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:16:in `call'
/home/rubys/git/rails/activesupport/lib/active_support/tagged_logging.rb:22:in `tagged'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:16:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) 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.4.1) lib/rack/lock.rb:15:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/static.rb:62:in `call'
/home/rubys/git/rails/railties/lib/rails/engine.rb:479:in `call'
/home/rubys/git/rails/railties/lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
/home/rubys/git/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:95:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `each'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:23:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.4.1) lib/rack/handler/webrick.rb:13:in `run'
rack (1.4.1) lib/rack/server.rb:265:in `start'
/home/rubys/git/rails/railties/lib/rails/commands/server.rb:70:in `start'
/home/rubys/git/rails/railties/lib/rails/commands.rb:55
/home/rubys/git/rails/railties/lib/rails/commands.rb:50:in `tap'
/home/rubys/git/rails/railties/lib/rails/commands.rb:50
script/rails:6:in `require'
script/rails:6
app/views/layouts/application.html.erb:20:in `_app_views_layouts_application_html_erb__1076610244_69891758384860'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:145:in `send'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:145:in `render'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:125:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_view/template.rb:143:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/template_renderer.rb:18:in `render'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/renderer.rb:36:in `render_template'
/home/rubys/git/rails/actionpack/lib/action_view/renderer/renderer.rb:17:in `render'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:110:in `_render_template'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/streaming.rb:225:in `_render_template'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:103:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:88:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:16:in `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `render'
/home/rubys/git/rails/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/benchmark.rb:308: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 `render'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
/home/rubys/git/rails/activerecord/lib/active_record/railties/controller_runtime.rb:24: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:196: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/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:167:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/callbacks.rb:18:in `process_action'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:414:in `_run__1118320962__process_action__199225275__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81: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:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:123:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/rubys/git/rails/activesupport/lib/active_support/notifications.rb:123:in `instrument'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/rubys/git/rails/actionpack/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/home/rubys/git/rails/activerecord/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/rubys/git/rails/actionpack/lib/abstract_controller/base.rb:121:in `process'
/home/rubys/git/rails/actionpack/lib/abstract_controller/rendering.rb:45:in `process'
/home/rubys/git/rails/actionpack/lib/action_controller/metal.rb:203: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:246:in `action'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:73:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:36:in `call'
/home/rubys/git/journey/lib/journey/router.rb:68:in `call'
/home/rubys/git/journey/lib/journey/router.rb:56:in `each'
/home/rubys/git/journey/lib/journey/router.rb:56:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:600:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/head.rb:14: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:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/query_cache.rb:64:in `call'
/home/rubys/git/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:28:in `call'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `_run__397314981__call__4__callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81:in `send'
/home/rubys/git/rails/activesupport/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:32:in `call_app'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:16:in `call'
/home/rubys/git/rails/activesupport/lib/active_support/tagged_logging.rb:22:in `tagged'
/home/rubys/git/rails/railties/lib/rails/rack/logger.rb:16:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) 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.4.1) lib/rack/lock.rb:15:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/middleware/static.rb:62:in `call'
/home/rubys/git/rails/railties/lib/rails/engine.rb:479:in `call'
/home/rubys/git/rails/railties/lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
/home/rubys/git/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:95:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `each'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:92:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:23:in `start'
/home/rubys/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.4.1) lib/rack/handler/webrick.rb:13:in `run'
rack (1.4.1) lib/rack/server.rb:265:in `start'
/home/rubys/git/rails/railties/lib/rails/commands/server.rb:70:in `start'
/home/rubys/git/rails/railties/lib/rails/commands.rb:55
/home/rubys/git/rails/railties/lib/rails/commands.rb:50:in `tap'
/home/rubys/git/rails/railties/lib/rails/commands.rb:50
script/rails:6:in `require'
script/rails:6
Request
Parameters:
None
Show session dump
_csrf_token: "8hL+UJey3VqNwGGoOtTSLofxBrO0uZipMlBTp5MkICk="
cart_id: 3
session_id: "d88f9dc75b86b88f7eaf8c83af7e819e"
Show env dump
GATEWAY_INTERFACE: "CGI/1.1"
HTTP_ACCEPT: "text/html"
REMOTE_ADDR: "127.0.0.1"
REMOTE_HOST: "localhost"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"
Response
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_jquery :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.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.......
Finished in 0.551677 seconds.
7 tests, 28 assertions, 0 failures, 0 errors
Loaded suite /home/rubys/.rvm/gems/ruby-1.8.7-p352/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
.........................
Finished in 1.203491 seconds.
25 tests, 42 assertions, 0 failures, 0 errors
Save our progress
git commit -a -m "AJAX"
[master 985f11f] AJAX
3 files changed, 39 insertions(+), 19 deletions(-)
git tag iteration-f
12.1 Iteration G1: Capturing an Order
11.5 Iteration F5: Making Images Clickable