biqut2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Oct-25 17:53 UTC
Capture form input from text_field and modify data
I''m new to ruby and just trying to toech myself ruby on rails. I''ve got a shopping cart and I need to be able te specify product quantity while in the cart. I have succefully created a link to incriment the quantity but I would like to be able to grab a number from a text_field and use it as the new quantity. The incriment feature is implimented as follows: This is in my view: <%= link_to("<font color=green>(add)</font>", :action => :update_cart, :id => product.id) %> This is in my store controller: def update_cart product = Product.find(params[:id]) @cart.update_product(product) flash[:notice] = "Item quantity has been updated" redirect_to(:action => :display_cart) end This is in my cart class: def update_product(product) item = @items.find {|i| i.product_id == product.id} item.quantity += 1 @total_price += product.price @total_shipping += product.shipping end I''m clueless here and could really use some help. TIA --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---