It gives me the following error: "undefined method 'latest_comment' for Post:Class"
Shouldn't the association create these methods automatically? What am I doing wrong? Should I specify attr_accessor :latest_comment? I can't seem to find anything on the internet that refernces this problem. Any of you have any ideas? Thanks in advance!
I've figured out the problem. I was trying to reference the method directly from Post, when I should have created an instance of it. This code will work:
test_comment_body = Post.new.latest_comment.body
If anyone knows a way to reference methods without having to create a new instance (is this even possble?), can you let me know? Thanks