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

No Method Error (driving me insane)

Recently made some changes to the index.htm for status. It tells me that I have an undefined method called full_name. However, I define it in my models under user. I have no idea why it can't find it and apply it..

| <strong><%= status.user.full_name %></strong> | <-- problem code

7 Answers

It might be a good idea to give the full error message? If it's undefined method called full_name on nil object then the problem is not the code but that you have a status with a nil user id.

When you delete all your statuses and readd them to you see the same problem?

Rich

Yes,

I have no current status and it still pops out an error.

I went on with the videos saving/changing and now a bigger problem occurred. When I start up my rails server it automatically exits me out.

Ah, but again. Need to know what the exact error message in the log file is. There's lots of reasons why the application server might not start.

So after you type "rails server" what is the output in the terminal? Copy and paste it and put it in the reply.

=> Booting WEBrick => Rails 3.2.12 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:469:in load': /users/sungmoon/treebook/app/models/user.rb:26: syntax error, unexpected ':', expecting keyword_end (SyntaxError) uniqueness: true ^ /users/sungmoon/treebook/app/models/user.rb:27: syntax error, unexpected ':', expecting keyword_end format: { ^ from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:469:inblock in load_file' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:639:in new_constants_in' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:468:inload_file' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:353:in require_or_load' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:502:inload_missing_constant' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:192:in block in const_missing' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:190:ineach' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:190:in const_missing' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:230:inblock in constantize' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in each' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:inconstantize' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:554:in get' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:588:inconstantize' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise.rb:272:in get' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/mapping.rb:77:into' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/mapping.rb:72:in modules' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/mapping.rb:89:inroutes' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/mapping.rb:156:in default_used_route' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/mapping.rb:66:ininitialize' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise.rb:306:in new' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise.rb:306:inadd_mapping' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/rails/routes.rb:208:in block in devise_for' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/rails/routes.rb:207:ineach' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/devise-2.2.4/lib/devise/rails/routes.rb:207:in devise_for' from /users/sungmoon/treebook/config/routes.rb:2:inblock in <top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:in instance_exec' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:282:ineval_block' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:260:in draw' from /users/sungmoon/treebook/config/routes.rb:1:in<top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in load' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:inblock in load' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in load_dependency' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:inload' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:ineach' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in load_paths' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:16:inreload!' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:26:in block in updater' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:incall' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in execute' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:27:inupdater' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:7:in execute_if_updated' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application/finisher.rb:66:inblock in <module:Finisher>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:30:in instance_exec' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:30:inrun' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:55:in block in run_initializers' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:54:ineach' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/initializable.rb:54:in run_initializers' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/application.rb:136:ininitialize!' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in method_missing' from /users/sungmoon/treebook/config/environment.rb:5:in<top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in require' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:inblock in require' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in load_dependency' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:inrequire' from /users/sungmoon/treebook/config.ru:3:in block in <main>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:51:ininstance_eval' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:51:in initialize' from /users/sungmoon/treebook/config.ru:innew' from /users/sungmoon/treebook/config.ru:in <main>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:40:ineval' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:40:in parse_file' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/server.rb:200:inapp' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in app' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/server.rb:304:inwrapped_app' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/server.rb:254:in start' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/server.rb:70:instart' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:55:in block in <top (required)>' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:50:intap' from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:50:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `<main>'

Yeah, so when your reading the output script you have to laser focus onto the first few lines as this is normally the most diagnostic. In your case they are:

load': /users/sungmoon/treebook/app/models/user.rb:26: syntax error, unexpected ':', expecting keyword_end (SyntaxError) uniqueness: true ^ /users/sungmoon/treebook/app/models/user.rb:27: syntax error, unexpected ':', expecting keyword_end format: { ^ from /usr/local/rvm/gems/ruby-1.9.3- p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:469

So what it is telling you is that you have a syntax error in user.rb around line 26 or 27 and that there is a semi colon there which it isn't expecting. It's not an exact solution. The code fix isn't definetly line 26 or 27 and it isn't definetly to remove a semi colon but it is an error that became apparent by that line and that character.

What is for sure is that there is a problem with that there is an error in that file and the server won't start until you've fixed it.

Rich

Hey Rich,

Thanks a lot man. When I first saw the error message I had no idea where to start, but your guidance gave me a good range to start. I haven't found the problem yet, but I'll keep working with it!

John

Good, that's exactly the right attitude. :-)

Oh, and remeber you probably have it saved in git when it was working. So you can do

git diff

To see what has changed.

Rich