Your Pragmatic Cart
- 1 × Pragmatic Project Automation
8.4 Iteration C3: Handling Errors 8.2 Iteration C1: Creating a Cart
edit app/models/cart_item.rb
class CartItem
attr_reader :product, :quantity
def initialize(product)
@product = product
@quantity = 1
end
def increment_quantity
@quantity += 1
end
def title
@product.title
end
def price
@product.price * @quantity
end
end
edit app/models/cart.rb
def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
current_item.increment_quantity
else
@items << CartItem.new(product)
end
end
edit app/views/store/add_to_cart.html.erb
<h2>Your Pragmatic Cart</h2>
<ul>
<% for item in @cart.items %>
<li><%= item.quantity %> × <%= item.title %></li>
<% end %>
</ul>
get /store/add_to_cart/2
undefined method `product' for #<Product:0x000000041a8138>
Rails.root: /home/rubys/git/awdwr/edition3/work-192-30/depot
app/models/cart.rb:10:in `block in add_product'
app/models/cart.rb:10:in `each'
app/models/cart.rb:10:in `find'
app/models/cart.rb:10:in `add_product'
app/controllers/store_controller.rb:11:in `add_to_cart'
/home/rubys/git/rails/activemodel/lib/active_model/attribute_methods.rb:392:in `method_missing'
/home/rubys/git/rails/activerecord/lib/active_record/attribute_methods.rb:46:in `method_missing'
/home/rubys/git/rails/activerecord/lib/active_record/attribute_methods.rb:44:in `method_missing'
/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__20526676238474905__process_action__1702769685223783392__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:62:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:27: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:75: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:493: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.4) 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.4) 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.4) 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.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11: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.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
/home/rubys/git/rails/activemodel/lib/active_model/attribute_methods.rb:392:in `method_missing'
/home/rubys/git/rails/activerecord/lib/active_record/attribute_methods.rb:46:in `method_missing'
/home/rubys/git/rails/activerecord/lib/active_record/attribute_methods.rb:44:in `method_missing'
app/models/cart.rb:10:in `block in add_product'
app/models/cart.rb:10:in `each'
app/models/cart.rb:10:in `find'
app/models/cart.rb:10:in `add_product'
app/controllers/store_controller.rb:11:in `add_to_cart'
/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__20526676238474905__process_action__1702769685223783392__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:62:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:27: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:75: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:493: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.4) 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.4) 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.4) 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.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11: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.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Parameters:
{"id"=>"2"}
cart: #<Cart:0x000000041a81d8 @items=[#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:36aca68,'0.2995E2',18(18)>>, #<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:3689630,'0.285E2',18(18)>>]>
GATEWAY_INTERFACE: "CGI/1.1" HTTP_ACCEPT: "text/html" HTTP_COOKIE: "_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly" HTTP_HOST: "localhost:3000" HTTP_USER_AGENT: "Ruby" HTTP_VERSION: "HTTP/1.1" PATH_INFO: "/store/add_to_cart/2" QUERY_STRING: "" REMOTE_ADDR: "127.0.0.1" REMOTE_HOST: "localhost" REQUEST_METHOD: "GET" REQUEST_PATH: "/" REQUEST_URI: "http://localhost:3000/store/add_to_cart/2" SCRIPT_NAME: "" SERVER_NAME: "localhost" SERVER_PORT: "3000" SERVER_PROTOCOL: "HTTP/1.1" SERVER_SOFTWARE: "WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)" action_controller.instance: #<StoreController:0x0000000409e990 @action_has_layout=true, @view_context_class=nil, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_response=#<ActionDispatch::Response:0x0000000409e800 @writer=#<Proc:0x0000000409e6c0@/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:0x0000000409e828 @env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/store/add_to_cart/2", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/store/add_to_cart/2", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x000000042a7278>, "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"=>"2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"cart"=>#<Cart:0x000000041a81d8 @items=[#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:36314a8,'0.2995E2',18(18)>>, #<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:35f2cf8,'0.285E2',18(18)>>]>}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"}, "rack.request.cookie_string"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil}, "rack.session.record"=>#<ActiveRecord::SessionStore::Session id: 1, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DFB...", created_at: "2011-12-25 00:59:36", updated_at: "2011-12-25 00:59:36">, "action_dispatch.request.path_parameters"=>{:controller=>"store", :action=>"add_to_cart", :id=>"2"}, "action_controller.instance"=>#<StoreController:0x0000000409e990 ...>, "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"=>{"controller"=>"store", "action"=>"add_to_cart", "id"=>"2"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @request_method="GET", @filtered_parameters={"controller"=>"store", "action"=>"add_to_cart", "id"=>"2"}, @method="GET", @fullpath="/store/add_to_cart/2">>, @_request=#<ActionDispatch::Request:0x0000000409e828 @env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/store/add_to_cart/2", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/store/add_to_cart/2", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x000000042a7278>, "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"=>"2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"cart"=>#<Cart:0x000000041a81d8 @items=[#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:35b58a8,'0.2995E2',18(18)>>, #<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:35b3418,'0.285E2',18(18)>>]>}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"}, "rack.request.cookie_string"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil}, "rack.session.record"=>#<ActiveRecord::SessionStore::Session id: 1, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DFB...", created_at: "2011-12-25 00:59:36", updated_at: "2011-12-25 00:59:36">, "action_dispatch.request.path_parameters"=>{:controller=>"store", :action=>"add_to_cart", :id=>"2"}, "action_controller.instance"=>#<StoreController:0x0000000409e990 ...>, "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"=>{"controller"=>"store", "action"=>"add_to_cart", "id"=>"2"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @request_method="GET", @filtered_parameters={"controller"=>"store", "action"=>"add_to_cart", "id"=>"2"}, @method="GET", @fullpath="/store/add_to_cart/2">, @_env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/store/add_to_cart/2", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/store/add_to_cart/2", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x000000042a7278>, "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"=>"2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"cart"=>#<Cart:0x000000041a81d8 @items=[#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:359f9e0,'0.2995E2',18(18)>>, #<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:359a030,'0.285E2',18(18)>>]>}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"}, "rack.request.cookie_string"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil}, "rack.session.record"=>#<ActiveRecord::SessionStore::Session id: 1, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DFB...", created_at: "2011-12-25 00:59:36", updated_at: "2011-12-25 00:59:36">, "action_dispatch.request.path_parameters"=>{:controller=>"store", :action=>"add_to_cart", :id=>"2"}, "action_controller.instance"=>#<StoreController:0x0000000409e990 ...>, "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"=>{"controller"=>"store", "action"=>"add_to_cart", "id"=>"2"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @lookup_context=#<ActionView::LookupContext:0x0000000409d978 @details_key=nil, @details={:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]}, @skip_default_locale=false, @frozen_formats=false, @view_paths=[/home/rubys/git/awdwr/edition3/work-192-30/depot/app/views]>, @_action_name="add_to_cart", @_response_body=nil, @_config={}, @_params={"controller"=>"store", "action"=>"add_to_cart", "id"=>"2"}, @cart=#<Cart:0x000000041a81d8 @items=[#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:355a458,'0.2995E2',18(18)>>, #<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:35146d8,'0.285E2',18(18)>>]>> 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: {"controller"=>"store", "action"=>"add_to_cart", "id"=>"2"} action_dispatch.request.path_parameters: {:controller=>"store", :action=>"add_to_cart", :id=>"2"} action_dispatch.request.query_parameters: {} action_dispatch.request.request_parameters: {} action_dispatch.secret_token: "2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200" action_dispatch.show_exceptions: true rack.errors: #<IO:<STDERR>> rack.input: #<StringIO:0x000000042a7278> rack.multiprocess: false rack.multithread: false rack.request.cookie_hash: {"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil} rack.request.cookie_string: "_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly" rack.request.query_hash: {} rack.request.query_string: "" rack.run_once: false rack.session: {"cart"=>#<Cart:0x000000041a81d8 @items=[#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:34e1440,'0.2995E2',18(18)>>, #<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:34da6e0,'0.285E2',18(18)>>]>} rack.session.options: {:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"} rack.session.record: #<ActiveRecord::SessionStore::Session id: 1, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DFB...", created_at: "2011-12-25 00:59:36", updated_at: "2011-12-25 00:59:36"> rack.url_scheme: "http" rack.version: [1, 1]
Headers:
None
rake db:sessions:clear
get /store/add_to_cart/2
get /store/add_to_cart/2
get /store/add_to_cart/3
get /store/add_to_cart/wibble
Couldn't find Product with ID=wibble
Rails.root: /home/rubys/git/awdwr/edition3/work-192-30/depot
app/controllers/store_controller.rb:9:in `add_to_cart'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:306:in `find_one'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:291:in `find_with_ids'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:107:in `find'
/home/rubys/git/rails/activerecord/lib/active_record/base.rb:444:in `find'
/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__20526676238474905__process_action__1702769685223783392__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:62:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:27: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:75: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:493: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.4) 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.4) 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.4) 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.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11: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.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:306:in `find_one'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:291:in `find_with_ids'
/home/rubys/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:107:in `find'
/home/rubys/git/rails/activerecord/lib/active_record/base.rb:444:in `find'
app/controllers/store_controller.rb:9:in `add_to_cart'
/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__20526676238474905__process_action__1702769685223783392__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:62:in `call'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
/home/rubys/git/rails/actionpack/lib/action_dispatch/routing/route_set.rb:27: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:75: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:493: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.4) 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.4) 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.4) 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.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11: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.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/rubys/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Parameters:
{"id"=>"wibble"}
cart: #<Cart:0x00000001cbdb20 @items=[#<CartItem:0x00000001cbd878 @product=#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41ddc48,'0.2995E2',18(18)>>, @quantity=2>, #<CartItem:0x00000001cbaad8 @product=#<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41d8658,'0.285E2',18(18)>>, @quantity=1>]>
GATEWAY_INTERFACE: "CGI/1.1" HTTP_ACCEPT: "text/html" HTTP_COOKIE: "_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly" HTTP_HOST: "localhost:3000" HTTP_USER_AGENT: "Ruby" HTTP_VERSION: "HTTP/1.1" PATH_INFO: "/store/add_to_cart/wibble" QUERY_STRING: "" REMOTE_ADDR: "127.0.0.1" REMOTE_HOST: "localhost" REQUEST_METHOD: "GET" REQUEST_PATH: "/" REQUEST_URI: "http://localhost:3000/store/add_to_cart/wibble" SCRIPT_NAME: "" SERVER_NAME: "localhost" SERVER_PORT: "3000" SERVER_PROTOCOL: "HTTP/1.1" SERVER_SOFTWARE: "WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)" action_controller.instance: #<StoreController:0x000000044342d0 @action_has_layout=true, @view_context_class=nil, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_response=#<ActionDispatch::Response:0x00000004434140 @writer=#<Proc:0x00000004434078@/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:0x00000004434168 @env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/store/add_to_cart/wibble", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/store/add_to_cart/wibble", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x0000000269b3b8>, "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"=>"2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"cart"=>#<Cart:0x00000001cbdb20 @items=[#<CartItem:0x00000001cbd878 @product=#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41cdf00,'0.2995E2',18(18)>>, @quantity=2>, #<CartItem:0x00000001cbaad8 @product=#<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41ccf38,'0.285E2',18(18)>>, @quantity=1>]>}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"}, "rack.request.cookie_string"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil}, "rack.session.record"=>#<ActiveRecord::SessionStore::Session id: 2, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DUN...", created_at: "2011-12-25 00:59:45", updated_at: "2011-12-25 00:59:46">, "action_dispatch.request.path_parameters"=>{:controller=>"store", :action=>"add_to_cart", :id=>"wibble"}, "action_controller.instance"=>#<StoreController:0x000000044342d0 ...>, "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"=>{"controller"=>"store", "action"=>"add_to_cart", "id"=>"wibble"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @request_method="GET", @filtered_parameters={"controller"=>"store", "action"=>"add_to_cart", "id"=>"wibble"}, @method="GET", @fullpath="/store/add_to_cart/wibble">>, @_request=#<ActionDispatch::Request:0x00000004434168 @env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/store/add_to_cart/wibble", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/store/add_to_cart/wibble", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x0000000269b3b8>, "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"=>"2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"cart"=>#<Cart:0x00000001cbdb20 @items=[#<CartItem:0x00000001cbd878 @product=#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41adc50,'0.2995E2',18(18)>>, @quantity=2>, #<CartItem:0x00000001cbaad8 @product=#<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41acc60,'0.285E2',18(18)>>, @quantity=1>]>}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"}, "rack.request.cookie_string"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil}, "rack.session.record"=>#<ActiveRecord::SessionStore::Session id: 2, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DUN...", created_at: "2011-12-25 00:59:45", updated_at: "2011-12-25 00:59:46">, "action_dispatch.request.path_parameters"=>{:controller=>"store", :action=>"add_to_cart", :id=>"wibble"}, "action_controller.instance"=>#<StoreController:0x000000044342d0 ...>, "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"=>{"controller"=>"store", "action"=>"add_to_cart", "id"=>"wibble"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @request_method="GET", @filtered_parameters={"controller"=>"store", "action"=>"add_to_cart", "id"=>"wibble"}, @method="GET", @fullpath="/store/add_to_cart/wibble">, @_env={"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/store/add_to_cart/wibble", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"localhost", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/store/add_to_cart/wibble", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)", "HTTP_ACCEPT"=>"text/html", "HTTP_USER_AGENT"=>"Ruby", "HTTP_COOKIE"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "HTTP_HOST"=>"localhost:3000", "rack.version"=>[1, 1], "rack.input"=>#<StringIO:0x0000000269b3b8>, "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"=>"2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200", "action_dispatch.show_exceptions"=>true, "action_dispatch.remote_ip"=>127.0.0.1, "rack.session"=>{"cart"=>#<Cart:0x00000001cbdb20 @items=[#<CartItem:0x00000001cbd878 @product=#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41a7cd8,'0.2995E2',18(18)>>, @quantity=2>, #<CartItem:0x00000001cbaad8 @product=#<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41a6cc0,'0.285E2',18(18)>>, @quantity=1>]>}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"}, "rack.request.cookie_string"=>"_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly", "rack.request.cookie_hash"=>{"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil}, "rack.session.record"=>#<ActiveRecord::SessionStore::Session id: 2, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DUN...", created_at: "2011-12-25 00:59:45", updated_at: "2011-12-25 00:59:46">, "action_dispatch.request.path_parameters"=>{:controller=>"store", :action=>"add_to_cart", :id=>"wibble"}, "action_controller.instance"=>#<StoreController:0x000000044342d0 ...>, "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"=>{"controller"=>"store", "action"=>"add_to_cart", "id"=>"wibble"}, "action_dispatch.request.accepts"=>[text/html], "action_dispatch.request.formats"=>[text/html]}, @lookup_context=#<ActionView::LookupContext:0x00000004433628 @details_key=nil, @details={:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]}, @skip_default_locale=false, @frozen_formats=false, @view_paths=[/home/rubys/git/awdwr/edition3/work-192-30/depot/app/views]>, @_action_name="add_to_cart", @_response_body=nil, @_config={}, @_params={"controller"=>"store", "action"=>"add_to_cart", "id"=>"wibble"}> 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: {"controller"=>"store", "action"=>"add_to_cart", "id"=>"wibble"} action_dispatch.request.path_parameters: {:controller=>"store", :action=>"add_to_cart", :id=>"wibble"} action_dispatch.request.query_parameters: {} action_dispatch.request.request_parameters: {} action_dispatch.secret_token: "2837c6a08c310a72a61d4ec726f76b2263d2600d3f265b7293ee27f817dca704422981eb0fbaab7ef8b562a8cbddaa13cdccb3802177a7ec0cad113cfde91200" action_dispatch.show_exceptions: true rack.errors: #<IO:<STDERR>> rack.input: #<StringIO:0x0000000269b3b8> rack.multiprocess: false rack.multithread: false rack.request.cookie_hash: {"_session_id"=>"93cd758bee6385a660fc94bc70bbbb7c", "path"=>"/", "HttpOnly"=>nil} rack.request.cookie_string: "_session_id=93cd758bee6385a660fc94bc70bbbb7c; path=/; HttpOnly" rack.request.query_hash: {} rack.request.query_string: "" rack.run_once: false rack.session: {"cart"=>#<Cart:0x00000001cbdb20 @items=[#<CartItem:0x00000001cbd878 @product=#<Product id: 2, title: "Pragmatic Project Automation", description: "<p>\n <em>Pragmatic Project Automation</em> sh...", image_url: "/images/auto.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41970b8,'0.2995E2',18(18)>>, @quantity=2>, #<CartItem:0x00000001cbaad8 @product=#<Product id: 3, title: "Pragmatic Version Control", description: "<p>\n This book is a recipe-based approach t...", image_url: "/images/svn.jpg", created_at: "2011-12-25 00:59:03", updated_at: "2011-12-25 00:59:03", price: #<BigDecimal:41961e0,'0.285E2',18(18)>>, @quantity=1>]>} rack.session.options: {:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"93cd758bee6385a660fc94bc70bbbb7c"} rack.session.record: #<ActiveRecord::SessionStore::Session id: 2, session_id: "93cd758bee6385a660fc94bc70bbbb7c", data: "BAh7BkkiCWNhcnQGOgZFRm86CUNhcnQGOgtAaXRlbXNbB286DUN...", created_at: "2011-12-25 00:59:45", updated_at: "2011-12-25 00:59:46"> rack.url_scheme: "http" rack.version: [1, 1]
Headers:
None
8.4 Iteration C3: Handling Errors 8.2 Iteration C1: Creating a Cart