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

User.first_name

When I introduce @status.user.first_name I get an error that says "undefined method `user' for #<Status:0x43508d0>"

How do I create this method or find the equivalent method would be?

5 Answers

Kevin Kenger
Kevin Kenger
32,834 Points

Hey Griffin,

Are you using Rails 4? If you are, and you're following along with the videos exactly, there's a good chance you've been trying to use attr_accessible which isn't used in Rails 4. You're going to have to use strong params.

Hopefully, this link</a> should take you to the forum post that will get you all straightened out. https://teamtreehouse.com/forum/devise-updated-with-ruby-211-and-rails-403

Hey Thanks for the reply. I am using Rails 4, and I have been aware that 'attr_accessible' isn't a part of 4, however I have been able to get by so far with no problems. I will give that article a read over and hopefully it helps!

Unfortunately, I have already tried installing 'protected_atrributes' and when I did so, something went terribly wrong and my server would no longer load up without an avalanche of errors. Is there not a way to address this in Rails 4 with the way it is set up?

Kevin Kenger
Kevin Kenger
32,834 Points

I went about the treebook app using strong params, which is the second suggestion in the forum post I linked to. I would suggest giving that a shot, because it's much more secure. But if you would like to use the protected_attributes gem, I can try and help. Could you post the errors you were getting?

It would be difficult for me to share them as I have already restarted from a previous build, in order to show them to you, I would have to replicate the process in which I seemingly corrupted my app. I am trying to learn with strong params right now, but achieving a similar outcome to the tutorial is proving difficult.