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 trialAndrew Allsop
3,751 PointsBuilding a Simple Rails Application : Creating Relationships with Rails 4 Problem
I'm unable to figure out how to create a relationship between my user_id and first_name. I'm using Rails 4 and Bootstrap 3 which is throwing up a number of problems.
In order to use attr_accessible I've installed the gem gem 'protected_attributes', however I can't remember if I've not used attr_accessible due to the different method in Rails 4 - I found I could progress without using it but didn't use another method in it's place.
I get the following error when trying to post a status:
#NoMethodError in Statuses#show
Showing /Users/andrewallsop/Documents/Personal/Development/treebook/app/views/statuses/show.html.erb where line #5 raised:
undefined method `first_name' for nil:NilClass
Rails.root: >/Users/andrewallsop/Documents/Personal/Development/treebook
Application Trace | Framework Trace | Full Trace
app/views/statuses/show.html.erb:5:in `_app_views_statuses_show_html_erb___486202422411280236_70355151938680'
2 Answers
Kang-Kyu Lee
52,045 PointsIf I were you, for Rails in treehouse, I would first go with "Odot" project. I've just downloaded project file of treebook and open the Gemfile, and rails version of it was '3.2.6'. But Rails does not use attr_accessible any more, since 4.0 -- It uses strong parameters.
Or, you may choose to install rails 3.2.6 first and go on with "Treebook"
David Curtis
11,301 Pointsdo they provide example code for this tutorial? if so, i would download it and check out how they do it.
Andrew Allsop
3,751 PointsThey provide example code but it's for a different version of rails/bootstrap.
David Curtis
11,301 PointsI had the same problem and had to start over using an older version of rails. Major bummer.
Andrew Allsop
3,751 PointsMy thinking now is that it's my only option. Without a doubt there's going to be more problems thrown up further down the course.
Andrew Allsop
3,751 PointsAndrew Allsop
3,751 PointsI think I'll install Rails 3.2 and download Bootstrap 2.0. I figure I can download the project files so I don't have to go over the whole thing again.
Kang-Kyu Lee
52,045 PointsKang-Kyu Lee
52,045 PointsHi Andrew. If you chose to go with Treebook project. Easiest way to start would be download and unzip project files and then go to the directory and do
bundle install
-- just in case, hope it helpsAndrew Allsop
3,751 PointsAndrew Allsop
3,751 PointsHello Kang,
Great idea :)
Thanks,
Andrew