Displaying 1 result from an estimated 1 matches for "list_all_categories".
2006 Feb 22
3
Listing/Relationship Question
...'t get
it!
What I want to do is click on a post and display all the categories that the
post is in.
class Post < ActiveRecord::Base
has_many :categories
end
class Category < ActiveRecord::Base
belongs_to :post
end
...simple enough.
In the categories_controller I have this:
def list_all_categories
@post = Post.find(params[:id])
@categories = Category.find_all(params[:post])
end
In the list_all_categories view:
<% @categories.each do |cat| %>
<%= cat.name%>
<% end %>
The problem is that all the categories are showing up, instead of just the
designated one(s)...