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

Michael Farley
PLUS
Michael Farley
Courses Plus Student 481 Points

undefined local variable or method

I have been following along and I can get the console to respond in the Blog app just fine. However, I've also been creating another app simultaneously called Quoting.

I've done: "bin/rails generate scaffold requester title:string city:string" and everything looks good in the web application, but note what happens below:

michaels-mbp:blog michaelfarley$ bin/rails console Running via Spring preloader in process 13088 Loading development environment (Rails 5.0.0.1) 2.3.1 :001 > Post.all Post Load (1.4ms) SELECT "posts".* FROM "posts" => #<ActiveRecord::Relation [#<Post id: 1, title: "How to program!", author: "Mike", created_at: "2016-11-22 20:25:23", updated_at: "2016-11-22 20:25:23">]> 2.3.1 :002 > exit michaels-mbp:blog michaelfarley$ cd .. michaels-mbp:~ michaelfarley$ cd quoting michaels-mbp:quoting michaelfarley$ bin/rails console Running via Spring preloader in process 13140 Loading development environment (Rails 5.0.0.1) 2.3.1 :001 > requesters.all NameError: undefined local variable or method requesters' for main:Object Did you mean? require from (irb):1 from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:instart' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in start' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:inconsole' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in run_command!' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in<top (required)>' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in require' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inblock in require' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in load_dependency' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:inrequire' from /Users/michaelfarley/quoting/bin/rails:9:in <top (required)>' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:inload' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in block in load' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:inload_dependency' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in load' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/commands/rails.rb:6:incall' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/command_wrapper.rb:38:in call' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:191:inblock in serve' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:161:in fork' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:161:inserve' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:131:in block in run' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:125:inloop' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application.rb:125:in run' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in<top (required)>' from /Users/michaelfarley/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /Users/michaelfarley/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from -e:1:in `<main>' 2.3.1 :002 >

1 Answer

Michael Farley
PLUS
Michael Farley
Courses Plus Student 481 Points

Hi...just noticed that maybe the first part of the problem was capitalization. Now I'm getting a different error:

2.3.1 :001 > Requesters.all NameError: uninitialized constant Requesters from (irb):1 from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in start' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:instart' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in console' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:inrun_command!' from /Users/michaelfarley/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in <top (required)>' from /Users/michaelfarley/quoting/bin/rails:9:in<top (required)>' from /Users/michaelfarley/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require' from /Users/michaelfarley/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire' from -e:1:in `<main>' 2.3.1 :002 >