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

Adam Posey
PLUS
Adam Posey
Courses Plus Student 7,823 Points

Simple Application: Treebook. Inconsistent error messages, no attr:accessible

So I'm following the tutorial and videos in making Treebook, at the very beginning and in multiple instances I've been told to expect files which do not exist (I did not have to delete the index.html file as per the video) or when I opened a file it did not contain any attr: accessible lines to cause the error that I was told to look for. In fact, manually adding those lines caused an error to appear.

Is this simply due to improvements VoV in Rails/Ruby or am I going down a long path to confusion?

7 Answers

Adam Posey
PLUS
Adam Posey
Courses Plus Student 7,823 Points

I feel like there should at least be an introduction making it clear that the software used in the demos is deprecated.

Stone Preston
Stone Preston
42,016 Points

if you are using a different version of rails/ruby than the video uses you will run into some issues. The treebook videos use rails 3.2 and ruby 1.9.3 I believe.

Yep. Make sure you're using the same version of ruby and rails as the video. If you're using rails v4.0+, you're going to encounter issues as attr_accessor is no longer used in v4.0+.

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Had the same problems, but managed to solve them. For example, don't delete the file, if it does not exist. "attr: accessible" is not available in Rails4 by default anymore, but can be brought back in the new version of Rails if you insert this into your Gemfile:

gem 'protected_attributes'

But you will probably eventually encounter something that is not so easy to solve, as I did (posted on forum a few days ago), and so far nobody on the forum managed to help me in finding a solution.

Randy Wang
Randy Wang
9,291 Points

Thanks Maciej, just got past this mark using your fix... hopefully we will get help with the problems you mention...

Having the same issue. I realized earlier that it was to do with an update to rails, but now I'm at a point (5:24 into "Creating Relationships") where if I add the name it will accept it, but then won't show that a name has been added. If I add the gem, will I then need to go back and figure out all the stuff that I didn't add earlier?

same problem here !

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Basically, in order to follow all Treebook videos without issues, you have to generate your fresh Treebook application specifying which version of Rails you want to use. I think they use 3.1 in the videos, 3.2 should probably work as well. This is the console command you are looking for:

rails _3.1.0_ new treebook

That's the way I'm going to tackle this from scratch. Remember to use those underscores around the desired Rails version! This will include proper settings and once you run bundle install, this should make your app download and use this particular version of Rails (not the newest one). There are many differences between Rails 3 and 4. This can be an interesting learning experience - once you're done with Treebook in 3.1, trying to remake it using version 4.0 properly.

An older version of Ruby is also used in the videos. I'm not sure if the changes between Ruby 1.9 (in videos) and 2.1 (today) will affect this project, but this is also an opportunity for you to learn how to use Ruby version management with rvm or rbenv (Linux) or pik (Windows) - no idea about Mac, I have literally zero experience with Macs, I'never even touched one.

I consider all those problems a good thing - they made me go out there and look for answers.