This brings the comments with post_id=8
@onepost = Post.find(8)
@allpostsWithAssoc = @onepost.comments
But this doesn’t bring the comments with post_id=8, but why ?
@onepost = Post.where(:id => 8)
@allpostsWithAssoc = @onepost.comments
I get
undefined method `comments' for #<ActiveRecord::Relation:0x9ecfce4>
The result of
@onepost = Post.where(:id => 8)is a collection (or Array) of all Post records which matched the condition, not the the record itself. try this: