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 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.