Ruby on Rails
Wednesday, February 15, 2017
I am pretty close to figuring this out...
I've got this in my product show page....I'm trying to pass user_id & product_id to my products controller, add_to_cart method...
<%= button_to 'Add to Cart', {:controller => "products", :action => "add_to_cart", :user_id=> session[:user_id], :product_id => @id } , :method=>:post %>
on the controller...
def add_to_cart(user_id, product_id)
@cart = Cart.new(user_id, product_id )#endI get the error,"wrong number of arguments (given 0, expected 2)"
Any suggestions?
Thanks,
Joe
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/284464e1-0de2-48ea-85e4-4c871fd47022%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment