Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby ActiveRecord Basics Migrations and Relationships Relationships

I am confused by the addition of the blogpost_id. What should I be looking for concept-wise in the rails docs?

OK so I tried the basic belongs to ... has many relationship:

lass BlogPost < ActiveRecord::Base has_many :comments end

class Comment < ActiveRecord::Base belongs_to :blogpost end

... "but I guess that relationship didn't work out" as far as the question was concerned. (Pun intended)

I have tried different combinations of this syntax and tried a few different variations, but apparently I am amiss somewhere. I'm sure the addition of the blogpost_id must be throwing a curve ball in this, but if it is something covered in the video, I missed it and am having a hard time finding it. Please let me know how to approach this problem. Thanks for hearing out my question :)

This is the last objective I haven't completed on this course, and I am revisiting this now having completed everything else..

models.rb
class BlogPost < ActiveRecord::Base
end

class Comment < ActiveRecord::Base
end

2 Answers

David Chapman
David Chapman
22,023 Points

Hi David Thrower! The comment about the blogpost_id is only explanatory—it doesn't need to be referenced in your code as it's handled by Rails for you.

Your challenge will pass if you add an underscore to blogpost: belongs_to :blog_post

David,

Thank you for your response. I got past this one and even completed the rails development track. I see that I had just made a typo that I was missing. .. Thanks. Feel free to collaborate in the future.