In the book 'Agile web development with Rails", the authors are building
a store-like app. At some point they add dynamic adding a product with
ajax call.
<!-- store_controller#index -->
<% form_remote_tag :url => { :action => 'add_to_cart', :id => product }
do %>
<%= submit_tag "Add to Cart" %>
<% end %>
# model cart.rb / no DB table
def add_to_cart(product)
current_item = @items.find {|item| item.product == product}
if current_item
current_item.increment_quantity
else
current_item = CartItem.new(product)
@items << current_item
end
current_item
end
Is there a way to add a text field which will represent the quantity of
the product to add in the cart ? Customer enter quantity in text field,
click Add to cart and the product and quantity is added to the
model/cart.
“Are you saying they aren’t using the 'better ways” of doing things in
the
latest tutorial that is in their latest book for Rails 3? (Just curious
because I’m using it as a guide for my learning as well.) "
the book for rails 3 is not out , it will be out in January 2011
On Sun, Sep 19, 2010 at 8:21 AM, radhames brito [email protected]
wrote:
surely , but i warn you that that tutorial {in the book 'Agile web
development with Rails"} is very old, there are better way to do everything
now.
Are you saying they aren’t using the 'better ways" of doing things in
the
latest tutorial that is in their latest book for Rails 3? (Just curious
because I’m using it as a guide for my learning as well.)
“Are you saying they aren’t using the 'better ways” of doing things in the
latest tutorial that is in their latest book for Rails 3? (Just curious
because I’m using it as a guide for my learning as well.) "
the book for rails 3 is not out , it will be out in January 2011