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 trialHarrison Hondo
7,283 PointsError when typing Employee.first into console
I am getting this error when typing Employee.first into the rails console while trying to follow along with the video at 8:20. The other commands Customer.first and Account.first work just fine though.
Employee Load (1.8ms) SELECT `employees`.* FROM `employees` ORDER BY `employees`.`id` ASC LIMIT 1
Mysql2::Error: Table 'biller_development.employees' doesn't exist: SELECT `employees`.* FROM `employees` ORDER BY `employees`.`id` ASC LIMIT 1
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'biller_development.employees' doesn't exist: SELECT `employees`.* FROM `employees` ORDER BY `employees`.`id` ASC LIMIT 1
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `query'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `block in execute'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `block in log'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:460:in `log'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/mysql2_adapter.rb:231:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/mysql2_adapter.rb:235:in `exec_query'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:336:in `select'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/querying.rb:39:in `find_by_sql'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/relation.rb:638:in `exec_queries'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/relation.rb:514:in `load'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/relation.rb:243:in `to_a'
from /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/relation/finder_methods.rb:512:in `find_nth_with_limit'
... 5 levels...
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Library/Ruby/Gems/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /Users/hsh2692/biller/bin/rails:8:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Library/Ruby/Gems/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
1 Answer
Charles Smith
7,575 PointsI think Hampton addresses this in the video. Watch from 6:20 on. If that didn't work, i would make sure that you have setup employee model correctly.
Harrison Hondo
7,283 PointsHarrison Hondo
7,283 PointsAll he does at 6:20 is another rake db:migrate. A little bit after that he runs into an error doing Customer.first that looks like mine but he fixes it by replacing the ActiveRecord::Base in customer.rb and employee.rb. I previously did both of these things and was then presented with this issue so I'm still not sure what to do about this.
Charles Smith
7,575 PointsCharles Smith
7,575 PointsI would look for typos and reload the console if you haven't already. It would seem that it's just not inheriting from the accounts table correctly.
Harrison Hondo
7,283 PointsHarrison Hondo
7,283 PointsFor some reason, I took a break, and when I came back the problem was fixed. Thanks for trying to assist me with this though.