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 trialrygelzwruy
7,931 PointsNoMethodError in Posts#index
It keeps saying: undefined method `body' for #<Post:0x007ff0bc7b78c0>
I did exactly as in the video, don't know what's wrong.. please help ^^
1 Answer
Samuel Ferree
31,722 PointsCan you show me the code for Post.rb and the migration that creates the post table?
it's not finding the body method/property on your Post model.
rygelzwruy
7,931 Pointsrygelzwruy
7,931 PointsThis is where it's giving me the error. Is this what you ment? It's the Index.html.erb
This is the post.rb
Samuel Ferree
31,722 PointsSamuel Ferree
31,722 PointsThe error is thrown when the view (index.html.erb) is rendered, but it exists because your post model doesn't have a body property. This could be because it doesn't have a column named body in the database, or what your controller is passing to the view for some reason doesn't have one.
What I see here looks fine, can you post your PostsController.rb and your Post migrations?
Samuel Ferree
31,722 PointsSamuel Ferree
31,722 PointsCan you also show me the terminal output from the following commands?