I just picked up Agile Web Development with Rails 3rd Ed. And I go through the Depot app chapters and I have a question about product / item options -
If I wanted to change the product catalog and save it so that the products could have parameters (size, color, whatever), where / how could I do this?
Say I sell T-shirts, and they come in different sizes. I don’t like the fact that it really needs a model created for handling sizes, so I thought that I could just add it as a selection window in html in the store view.
But each "Add to Cart" button is wrapped with a form tag that is automatically generated by button_to and does not seem to allow me to pass additional parameters to my cart. How can I get the size of an element added in POST in add_to_cart?
And, perhaps more importantly , what is the most Railsy way to do this?
Thanks in advance for your help! --Mark
The assistant in my opinion:
<%= button_to "Add to Cart" , :action => :add_to_cart, :id => product %>
The form that it generates:
<form method="post" action="/store/add_to_cart/3" class="button-to">
Mark
source
share