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

I can't get my rails server running

I am getting an extremely long error when I run the rails server. I think it may have something to do with my user.rb model but i'm not sure. Also this is not the full code, I had to cut some pieces out. :

Last login: Wed Oct 16 11:59:48 on ttys001 Alicia-T-Glenns-MacBook:~ aliciatglenn$ cd code Alicia-T-Glenns-MacBook:code aliciatglenn$ cd treebook Alicia-T-Glenns-MacBook:treebook aliciatglenn$ rails s

=> Run rails server -h for more startup options => Ctrl-C to shutdown server Exiting /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in load': /Users/aliciatglenn/code/Treebook/app/models/user.rb:13: syntax error, unexpected ':', expecting keyword_end (SyntaxError) format: { ^ from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:inblock in load_file' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in new_constants_in' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:inload_file' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in require_or_load' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:inload_missing_constant' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in const_missing' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:inconst_get' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:in block in constantize' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:ineach' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in inject' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:inconstantize' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:534:in get' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:565:inconstantize' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise.rb:285:in get' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/mapping.rb:77:into' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/mapping.rb:72:in modules' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/mapping.rb:89:inroutes' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/mapping.rb:156:in default_used_route' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/mapping.rb:66:ininitialize' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise.rb:319:in new' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise.rb:319:inadd_mapping' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/rails/routes.rb:210:in block in devise_for' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/rails/routes.rb:209:ineach' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/devise-3.1.1/lib/devise/rails/routes.rb:209:in devise_for' from /Users/aliciatglenn/code/Treebook/config/routes.rb:3:inblock in '

from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in <top (required)>' from bin/rails:4:inrequire

Johan Prieto
Johan Prieto
6,513 Points

Okay so I have not used ROR in quite a long time but I'll take a stab at it. Are you using the same version that's being used in the tutorial? Also is this the first time you try to run your rails server? Or did you just now get this error, after making some changes?

3 Answers

Tony McKeown
PLUS
Tony McKeown
Courses Plus Student 14,300 Points

Alicia I downloaded a copy of your treebook and found the problem in the user.rb.

You missed a comma on line 12. Should be uniqueness:true,

Once I added the , the server starts

Thanks Tony, this seemed to work! Crazy how much a comma can do, I added that and removed the "def full_name first_name + " " + last_name" because that doesn't seem to work for some reason :/

Marcus Tisรคter
Marcus Tisรคter
4,886 Points

Have you tried bundle install? Could be a missing gem.

Tony McKeown
PLUS
Tony McKeown
Courses Plus Student 14,300 Points

Where are you having the problem with the full_name? The def action looks exactly the same as my treebook file but mine was built with the older version of rails.

On a different note I've just noticed in the user.rb file you have a spelling error for profile_name. You've mistyped it as ptofile_name.

I think some of the problems you are experiencing arise because you're using rails 4 and the videos were made using rails 3.2. Some of the code needed to create this project is slightly different in the newer version of rails. For example attr_accessible is not used in rails 4 like it was used in the videos which is why it won't allow you to save a profile because you cannot save to the database as those attributes are protected.

I noticed you are following Onemonthrails as well. Mattan discusses this in one of his videos but I can't remember which one off the top of my head.

Jason has produced a blog post about this as well. http://blog.teamtreehouse.com/rails-4-strong-paremeters

Thanks for the heads up on the spelling error. And yes I have been using one month rails, I'll probably have to refer back to it. I don't know what's going on with the full_name on my project. I think it might be an error from a previous issue, probably from the attr_accessible thing.I checked out the article, but I'm still not sure how to properly assign the strong parameters and I have ran into the same issue of my server not loading up :/.

Is there a typical answer for the server not loading?