I have a Product model with the following columns:
name:string
price:integer
I also have a cart model, line_item model, an orders controller: pretty basic but you get the idea.
What I need to do (and have done) is add size (since it's for tshirts) and color to the Product model. Fair enough,
rails g migration AddSizeToProducts size:string
works just fine and similarly for color.
The way the buying process is set up is as follows:
select shirt (one page)
after selecting shirt, takes you to next page
on this page, you will select both the color and size for the shirt.
From what I've gathered, using select
will not be tied to the database, so I suppose collection_select
would be more appropriate here? Or would something like this be OK?
<%= select @product, :id, [ ["Small",1], ["Medium",2], ["Large",3]] %>
Also, how would I "prepopulate" these fields with sizes ie small/med/large and colors ie black/blue/white without having them associated to a particular product before a product is selected (from step 1 above)?
Any input on the matter is appreciated.