Hello everyone. I trying to learn associations, but have a quick question that shouldn't be too hard.
I have a classifieds table that has a column category_id and I have a categories table. I put has_many :classifieds in the Category model and belongs_to :categories in the Classifieds model
I am trying to get the category for a classified from the view. What is the correct way to do this? I thought it would be something like:
<% for classified in @classifieds %> <%= classified.category.name %> <% end %>
but obviously it isn't working. What is the right way to do this? Thanks!
-Bradly