crowdint / acts_as_shopping_cart_app

Example app for acts_as_shopping_cart_gem
10 stars 13 forks source link

Add to cart function not working #3

Open tacoplz opened 9 years ago

tacoplz commented 9 years ago

Below is the log. I think the problem is the routes. Ive tried adding a post route to the routes file to no avail. Any help would be very much appreciated. I can provide more information if necessary. Thanks in advance!

Started POST "/shopping_cart/1" for 162.239.93.178 at 2015-07-07 02:17:00 +0000

ActionController::RoutingError (No route matches [POST] "/shopping_cart/1"):
 web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:22:in `middleware_call'
  web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.1) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.1) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
  rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.0) lib/rails/engine.rb:518:in `call'
  railties (4.2.0) lib/rails/application.rb:164:in `call'
  rack (1.6.1) lib/rack/content_length.rb:15:in `call'
  puma (2.11.1) lib/puma/server.rb:507:in `handle_request'
  puma (2.11.1) lib/puma/server.rb:375:in `process_client'
  puma (2.11.1) lib/puma/server.rb:262:in `block in run'
  puma (2.11.1) lib/puma/thread_pool.rb:104:in `call'
  puma (2.11.1) lib/puma/thread_pool.rb:104:in `block in spawn_thread'
tacoplz commented 9 years ago

Okay, I think I have a start on the routes, I added the following:

post   'shopping_carts/:shopping_cart_id' => 'shopping_carts#show'

however, now I get an error:

Started POST "/shopping_carts/3" for 162.239.93.178 at 2015-07-07 03:22:28 +0000
Processing by ShoppingCartsController#show as HTML
  Parameters:     {"authenticity_token"=>"Y5qQZLfyuTEVEBfbbq4xYrMyvF8A3wyrCnFvQOZvehAGSU+IvWjOjJxXVGSO4iPCdVOJyGCk8KsAyzwBfON3TQ==", "shopping_cart_id"=>"3"}
  ShoppingCart Load (0.2ms)  SELECT  "shopping_carts".* FROM "shopping_carts" WHERE "shopping_carts"."id" = ? LIMIT 1  [["id", 1]]
Completed 404 Not Found in 8ms

ActiveRecord::RecordNotFound (Couldn't find ShoppingCart with 'id'=1):
  app/controllers/shopping_carts_controller.rb:17:in `extract_shopping_cart'

I think this error has come about due to the ShoppingCart Load query's shopping_carts "id" defaulting to 1. Any suggestions?

bishisht commented 8 years ago

im also having the same error. the url is looking like http://localhost:3001/shopping_cart.1 instead of http://localhost:3001/shopping_cart/1

mibamur commented 8 years ago

Has someone solved it?