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 trialJustin Keller
15,742 PointsLooking at my code, how can the "`belongs_to` always wants the singular version of the relationship" be fixed?
Tried with :blogPost and :blogpost, as well as blog_post_id and :BlogPost
class BlogPost < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :BlogPost
end
1 Answer
Joshua Shroy
9,943 PointsHey Justin,
Since the BlogPost model name has Post capitalized, that would need to be set as blog_post
, so..
class Comment
belongs_to :blog_post
end
..should do the trick.