Hey,
I followed Ryan Bates tutorials here about implemting checkboxes with has and belongs to many relationships.
In case you dont have time to watch it, heres a quick summary--
Hey,
I followed Ryan Bates tutorials here about implemting checkboxes with has and belongs to many relationships.
In case you dont have time to watch it, heres a quick summary--
<%= @product.categories.map(&:name).to_sentence %>
Hmmm thanks for the reply.. but nothing is showing up. no error message though... is there a way to do this with a for loop?
I dont understand that peice of code.. im a rails noobie. could you breifly explain? Thanks
This is saying that a product has many categories. The category name will map to an array then the .to_sentence outputs each item as 1,2,3. nicely.
Thanks, but are you sure this works with has and belongs to many?
If you have a product instance you can do @product.categories correct which returns an array of categories?