You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upgraded from rails 4.0.0 to 4.1.5 and ran into an issue when attempting to destroy an object that has a has_and_belongs_to_many association to another join table.
The model setup is as follows:
class Group < ActiveRecord::Base
has_and_belongs_to_many :accounts_users
end
class AccountsUser < ActiveRecord::Base
belongs_to :account
belongs_to :user
end
class Account < ActiveRecord::Base
end
class User < ActiveRecord::Base
end
In the console:
g = Group.first
g.destroy()
Error:
ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect table name '': DELETE FROM `` WHERE `accounts_users_groups`.`group_id` = 14
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `query'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `block in execute'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:303:in `execute'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/mysql2_adapter.rb:228:in `execute'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/mysql2_adapter.rb:254:in `exec_delete'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/database_statements.rb:106:in `delete'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `delete'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/relation.rb:449:in `delete_all'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/associations/has_many_association.rb:122:in `delete_records'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/associations/collection_association.rb:255:in `delete'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/associations/collection_association.rb:198:in `delete_all'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/associations.rb:1596:in `destroy_associations'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activerecord-4.1.5/lib/active_record/persistence.rb:153:in `destroy'
... 17 levels...
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/railties-4.1.5/lib/rails/commands/console.rb:9:in `start'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:69:in `console'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
from /Users/Walsh/Sites/myapp/bin/rails:8:in `<top (required)>'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/Walsh/.rvm/gems/ruby-2.1.2@myapp/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
from /Users/Walsh/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/Walsh/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
The text was updated successfully, but these errors were encountered:
Upgraded from rails 4.0.0 to 4.1.5 and ran into an issue when attempting to destroy an object that has a has_and_belongs_to_many association to another join table.
The model setup is as follows:
In the console:
Error:
The text was updated successfully, but these errors were encountered: