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
Gary Insley
14,133 PointsHas & Belongs to Many - (Mysql2::Error: Table 'biller_development.employees_projects' doesn't exist)
I am following along with Hampton and have come across a problem when trying to access: Project.first.employee:
This is the code that i entered into IRB and the error message i received: (p = Project.first)
irb(main):003:0> p.employees
Mysql2::Error: Table 'biller_development.employees_projects' doesn't exist: SHOW FULL FIELDS FROM `employees_projects`
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'biller_development.employees_projects' doesn't exist: SHOW FULL FIELDS FROM `employees_projects`
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `query'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `block in execute'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `execute'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/mysql2_adapter.rb:228:in `execute'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:310:in `execute_and_free'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:451:in `columns'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/schema_cache.rb:93:in `block in prepare_default_proc'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/schema_cache.rb:44:in `yield'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/schema_cache.rb:44:in `columns'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/schema_cache.rb:97:in `block in prepare_default_proc'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/schema_cache.rb:50:in `yield'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/connection_adapters/schema_cache.rb:50:in `columns_hash'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/associations/association_scope.rb:47:in `column_for'
... 7 levels...
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/associations/association.rb:97:in `association_scope'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/associations/association.rb:86:in `scope'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/associations/collection_association.rb:404:in `scope'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/associations/collection_proxy.rb:36:in `initialize'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/relation/delegation.rb:106:in `new'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/relation/delegation.rb:106:in `create'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/associations/collection_association.rb:36:in `reader'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-4.1.4/lib/active_record/associations/builder/association.rb:110:in `employees'
from (irb):3
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/console.rb:90:in `start'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/console.rb:9:in `start'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:69:in `console'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/Gary/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>' ```
**strong** My EmployeesProjects Migration is set up as: **strong**
class EmployeesProjects < ActiveRecord::Migration
def change
create_table :employees_projects do |t|
t.belongs_to :employee, :project
t.timestamps
end
end
end
**strong** My Projects Module is set up as: **strong**
class Project < ActiveRecord::Base
belongs_to :customer
has_and_belongs_to_many :employees, :join_table => "employees_projects"
end
I believe i have followed along word for word and cannot seem to find where i have gone wrong, anyones help would be greatly appreciated....
Thanks