Dudebot
(Dudebot)
September 13, 2009, 8:56pm
1
I'm almost there... if someone could please help me
OK, if I have this in my .html.erb:
<%= button_to "Add to Cart" , :action => 'add_to_cart', :id =>
item, :amount => 3 %>
I get proper behavior. But I'm trying to figure out how to wire up a
text field for :amount
<%= text_field_tag '$', @amount %></p>
<%= button_to "Add to Cart" , :action => 'add_to_cart', :id =>
item, :amount => @amount %>
Doesn't work. Does anybody have an idea of what would?
add_to_cart is now working with
def add_to_cart
item = Item.find( params[ :id ] )
@cart = find_cart
@cart.add_item ( item, params[ :amount ] )
end
Can anyone help??
Many TIA,
Craig
I'm almost there... if someone could please help me
OK, if I have this in my .html.erb:
<%= button_to "Add to Cart" , :action => 'add_to_cart', :id =>
item, :amount => 3 %>
I get proper behavior. But I'm trying to figure out how to wire up a
text field for :amount
<%= text_field_tag '$', @amount %></p>
<%= button_to "Add to Cart" , :action => 'add_to_cart', :id =>
item, :amount => @amount %>
Doesn't work. Does anybody have an idea of what would?
You need a form. What button_to does is create a form containing just
a button, whereas you need a form containing both the textfield and
the submit button
Fred