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

rails generate migration add_user_id_to_statuses

I end up with the following error when I run the above command to add the relationship in my table.

NameError: undefined local variable or method `add_user_id_to_statuses' for main:Object




    from (irb):3
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/console.rb:110:in `start'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/console.rb:9:in `start'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
    from /Users/rizcube/Documents/makers/RailsTreehouse/Networking_site/treebook/bin/rails:8:in `<top (required)>'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/commands/rails.rb:6:in `call'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/command_wrapper.rb:38:in `call'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:183:in `block in serve'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:156:in `fork'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:156:in `serve'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:131:in `block in run'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:125:in `loop'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:125:in `run'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/rizcube/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'irb(main):004:0>

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Did you enter this command in IRB or in Rails Console? It should be done in your normal terminal, while in the project's folder. I just tried, this exact error appears when you type the command in rails console.