Routing Errors
SA
4 posts
|
I tried to add the cart, but when I clicked ont he add_to_cart button, nothing changed. I tried to manually load the add_to_cart.html.erb page and got the following error: I restarted Mongrel and tried again. Same error. Any ideas? Thanks:) Sa |
Sam Ruby
197 posts
|
I like your approach to debugging, trying it manually and then comparing it to what the application is trying to do. Let’s go with that. But it looks to me like you have the URI wrong. The following should add product #2 to the cart: |
SA
4 posts
|
Interestingly enough, when I try to manually load http://localhost:3000/store/add_to_cart/2 , I get redirected back to http://localhost:3000/store. Any ideas? Thanks:) Sa |
Sam Ruby
197 posts
|
OK, so get properly redirects, lets try post. Add the following as <form action="/store/add_to_cart/2"> <input type="submit"> </form> Then go to http://localhost:3000/testadd.html, and press Submit. |
SA
4 posts
|
I added the testadd page and clicked on the submit button. I was redirected to http://localhost:3000/store. This is the same as any other cart adds. |
SA
4 posts
|
I think I found my error. I had :id in the index.html.erb file and :object_id in the controller. Once I change :object_id to :id and restarted, everything is now working. Thanks:) |
Jason Frankl...
4 posts
|
just an after note: when ever you make any changes to routes.rb always resart the server. |
7 posts, 3 voices
