Render a partial that has assosciations with something else

hi,
Does anyone know how I can render a partial that has an assosciation
with something else (e.g. render a comments partial in posts-- where the
comments belong to posts).
Thanks

If you have your model associations setup properly you should be able
to access them using post.comments

For example:

class Post < ActiveRecord::Base
has_many :comments
end

class Comment < ActiveRecord::Base
belongs_to :post
end

In _post.rhtml you can do

<%= render :partial => “comment/comment”, :collection => post.comments
%>

That assumes you have a partial called _comment.rhtml in the “comment”
directory under views.

On Jul 21, 6:53 pm, John M. [email protected]

Thanks!