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!
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
Chase Lee
29,275 PointsNoMethodError in Statuses#show.
Hi,
I'm following along the ruby on rails course and ran into this error.
I added:
belongs_to :user
To my status.rb
file.
Is there anything other info that I could give you to help?
Thank you for your help!
-Chase

Adam Sackfield
Pro Student 19,663 PointsCan you post the code from your status.rb file and the statuses_controller file too please
4 Answers

Adam Sackfield
Courses Plus Student 19,663 PointsI would ideally change to rails 3.2, just to make life easier for yourself. But I believe to fix this error you can change the following in the controller
def status_params
params.require(:status).permit(:name, :content)
end
to this
def status_params
params.require(:status).permit(:content, :user_id)
end
This should fix your current error but you will run into more later down the line. Also I recommend starting with this tutorial for a better understanding of rails :)

Kevin Lozandier
Courses Plus Student 53,747 PointsFYI, Chase James: In general, do NOT use an entire version of Rails higher than what the class was intended for. Rails, like all serious frameworks, takes semantic versioning seriously.
Do not be surprised if things crash and not work despite you following the instructions exactly.
If you want to focus on Rails 4 as the version of Rails towards understanding Rails (totally understandable), take the Rails 4 courses first and perhaps revisit the Rails 3 courses available as extra credit to upgrade to Rails 4 apps after you actually understand Rails.
If you're beginning to understand Rails, do not try to do upgrade a significantly different version of Rails to a newer version of Rails as a beginner.

Chase Lee
29,275 PointsOkay thanks Kevin Lozandier. The reason I was doing that is because I'm trying to make my own social network app and am using the Treehosue courses as a launchpad to help me get started.

Kevin Lozandier
Courses Plus Student 53,747 PointsChase James: In order to do that, understand the basics of Rails with the latest stable version and then consider going through an older version of Rails that solves a particular problem you have.
Adam Sackfield means that older version of Rails will break if you try to update it to the new version, it has new techniques, dependencies, and features that can't translate with older version of Rails; and its features can't be migrated well to older version of Rails.
Get a solid understanding of Rails 4.x, and then come back to projects as old as this Rails 3 Social Networking app to not confuse yourself towards understanding the specific things you want from it towards making your own with modern Rails techniques.

Chase Lee
29,275 PointsThanks Kevin!

Adam Sackfield
Pro Student 19,663 PointsI did advise to change to version 3.2 if continuing the Treebook application and also pointed out a much more detailed text based tutorial written for 3.2 and 4, which is also a social networking app.

Kevin Lozandier
Courses Plus Student 53,747 PointsAdam Sackfield: I should have been clearer about that. I didn't think it was clear enough why Chase should change to Rails 3.2.
I've found it to be very confusing for new programmers used to desktop applications to think more than anything a new version of an "App" (Rails being a framework of course), will run an app made from an older version only better.
Of course, that's not the case with web frameworks, libraries, and systems.

Adam Sackfield
Pro Student 19,663 PointsI think you edited your OP anyway as I read it in email and then posted and checked your post and it had changed. But yes you are right these rails courses cause no end of confusion, I believe adding a short video to the start of each course explaining that the difference in version numbers will have a very big impact on your learning would help to alleviate some of these issues.
Even having links to some posts that have been duplicated and answered on numerous occasions would be a good start.

Chase Lee
29,275 PointsThanks Adam Sackfield! Here is my status.rb
code:
class Status < ActiveRecord::Base
belongs_to :user
end
And my statuses_controller.rb

Adam Sackfield
Pro Student 19,663 PointsAre you using rails version 4 or 3.2?

Chase Lee
29,275 PointsI'm using version 4. Do you think I should switch to version 3.2?

Chase Lee
29,275 PointsOkay, I'll try that. Thank you!

Adam Sackfield
Pro Student 19,663 PointsAnytime!!
Chase Lee
29,275 PointsChase Lee
29,275 PointsWhen I take out the
first_name
part the error goes away. Does that help? Thanks.