Hi,
I’m trying to develop a simple blog aplication, with no scaffolding
help. I create the model post and comment, and stablished the
asociations:
class Post < ActiveRecord::Base
has_many :comments
validates_presence_of :title, :poster, :content
end
class Comment < ActiveRecord::Base
belongs_to :post
end
But, when I try to get the comments in a post I get error:
SQLite3::SQLException: no such column: comments.post_id: SELECT * FROM
“comments” WHERE (“comments”.post_id = 18)
Extracted source (around line #7):
4:
5:
6:
7: <% for comment in @comments %>
8:
9:
No such column? Error in @comments, here is the controller:
def showcomments
@post = Post.find(params[:id])
@comments = @post.comments
end
I don’t know where the problem is :S
Thanks for your answers