Thanks Freddy! Although what I need help is with a different issue. Let me try to explain better. The quantity and cost fields are not the problem. The "Total" field is. This field is to get updated with cost*qty, as and when the user changes the qty. This is working successfully for me when i have a record of just one product in the cart. But when i add more products through an "Add product" ajax link, their respective "Total" fields dont work. I understand that i have to index every product i add to the cart in order for each of them to have an identity. But according to the Railscast 75, the accepted parameters cannot be processed in a setter method if the index is included in the array of attributes. Hope that makes it a bit clearer. Help!
On Oct 26, 3:38 am, Freddy Andersen <[EMAIL PROTECTED]> wrote: > The cost you should get when you get to the controller... Just send > the id of the product and find the cost when you get to the > controller... > > About the quantity, not sure about the observer but I just added a > remote_form that has the quantity property: > > <% remote_form_for :quantity, :url => { :controller => > "carts", :action => :add, :id => @product.id }, > :complete => visual_effect(:highlight, 'floating_cart') do |f| -%> > <%= f.select :quantity, (1..5) %> > <%= image_submit_tag("../images/add_to_cart.png", :class => > "submit_tag") %> > <% end %> > > This is for the cart model... adding a product to the cart... > item.update_attributes({ :amount => item.amount + quantity, > :price => product.price, > :weight => product.weight}) > cart_items << item --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---