Trace the flow through the methods save_order, add_line_items_from_cart, and from_cart_item. Do the controller, order model, and line item model seem suitably decoupled from each other? (One way to tell is to look at potential changes—if you change something, for example by adding a new field to a cart item, does that change ripple through the code?) Can you find a way to further reduce coupling? Discuss
What happens if you click the Checkout button in the sidebar while the checkout screen is already displayed? Can you find a way of disabling the button in this circumstance? (Hint: variables set in the controller are available in the layout as well as in the directly rendered template.) Discuss
The list of possible payment types is currently stored as a constant in the Order class. Can you move this list into a database table? Can you still make validation work for the field? Discuss
The checkout isn’t working for me, its not validating. It just goes straight to an error screen on /store/save_order that says
“NoMethodError in StoreController#save_order \ undefined method `quantity=’ for #“
The top two items from the stack are
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/base.rb:1860:in `method_missing’ \ /var/www/depot/app/models/line_item.rb:8:in `from_cart_item’
Check your database schema. Make sure you have a field called “quantity” (check spelling) of type integer in your LineItems table.
I get an error when I hit the checkout button. “undefined method `email’ for #“
This comes from the line that says ”<%= form.text_field :email, :size => 40 %>” I know that I spelled :email correctly in the order model, so I can’t figure out what on earth it’s talking about? Any ideas?
- V1: System [about 8 years ago]