Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Simple Ruby on Rails Application Customizing Forms Creating Relationships

Brandon Mowat
Brandon Mowat
8,186 Points

undefined method `user'

Im getting this error at this point in the lesson.

undefined method `user' for #<Status:0x007fd8cb0cc820>

<code> <% @statuses.each do |status| %> <div class="status"> <strong><%= status.user.first_name %></strong> <p><%= status.content %></p> <div class="meta"> <%= link_to time_ago_in_words(status.created_at)+" ago", status %> </code>

I don't know why my status class doesn't have the method user.

HELP

Calvin Nix
Calvin Nix
43,828 Points

Are you using Ruby on Rails version 4?

2 Answers

Calvin Nix
Calvin Nix
43,828 Points

Hey Brandon,

This issue is caused because attr_accessible is no longer used in rails 4 because it is not secure. Rails 4 now uses Strong Parameters instead. Please refer to this link for references to how to implement these changes. This is actually discussed in later videos. I had this same issue when doing the rails course.