I've table tournaments with fields user_id,question_id,answer and I created key like
Primary key (user_id, question_id)
But when I want to change answer field like this:
t=Tournament.where('question_id=200').first
t.answer=2
t.save
I've got error:
NoMethodError: undefined method `eq' for nil:NilClass
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.4/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/persistence.rb:255:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/locking/optimistic.rb:77:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/attribute_methods/dirty.rb:68:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/timestamp.rb:60:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:285:in `block in update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:413:in `_run_update_callbacks'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:285:in `update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/persistence.rb:246:in `create_or_update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:277:in `block in create_or_update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:423:in `_run_save_callbacks'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:277:in `create_or_update'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/persistence.rb:56:in `save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/validations.rb:49:in `save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:245:in `block in save!'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:207:in `transaction'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.4/lib/active_record/transactions.rb:245:in `save!'
from (irb):4
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands/console.rb:44:in `start'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands/console.rb:8:in `start'
from /home/marat/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.4/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
Can anyone help me?
Thanks.
Did you modify your tables at all from a standard Rails genearated one?
if so, see undefined method `eq' for nil:NilClass with rails 3 and ruby enterprise on ubuntu hardy
Related
I've got a (brand new) Rails 5 project that's throwing errors when I try to run migrations.
(I'm running Ruby 2.2.4 on a Raspberry Pi using PostgreSQL 9.4, but the same error message popped up when I first tried running the migration with SQLite.)
So far, the only migration I've got is pretty basic:
class CreateAuthors < ActiveRecord::Migration[5.0]
def change
create_table :authors do |t|
t.string :username
t.timestamps
end
end
end
This results in the following output when I run rake db:migrate.
pi#raspberrypi:~/projects/gnn $ rake db:migrate
== 20160915091621 CreateAuthors: migrating ====================================
-- create_table(:authors, {})
-> 0.0283s
== 20160915091621 CreateAuthors: migrated (0.0287s) ===========================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
undefined method `value_for_database' for #<Array:0x2a10470>
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `block in exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `each'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `map'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:587:in `execute_and_clear'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:103:in `exec_query'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:135:in `exec_insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:124:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:65:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:554:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/counter_cache.rb:128:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/locking/optimistic.rb:75:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:123:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `block in _create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_create_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/timestamp.rb:68:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:534:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `block in create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_save_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:152:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/validations.rb:50:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `block in save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:230:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/suppressor.rb:45:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:51:in `create!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1247:in `record_version_state_after_migrating'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1212:in `block in execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `block in ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1210:in `execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1183:in `block in migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `each'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `block in migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1298:in `with_advisory_lock'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
NoMethodError: undefined method `value_for_database' for #<Array:0x2a10470>
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `block in exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `each'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `map'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:597:in `exec_no_cache'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:587:in `execute_and_clear'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:103:in `exec_query'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:135:in `exec_insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:124:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/relation.rb:65:in `insert'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:554:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/counter_cache.rb:128:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/locking/optimistic.rb:75:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:123:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `block in _create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_create_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:302:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/timestamp.rb:68:in `_create_record'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:534:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `block in create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_save_callbacks'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/callbacks.rb:298:in `create_or_update'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:152:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/validations.rb:50:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/attribute_methods/dirty.rb:30:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `block in save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:230:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:324:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/suppressor.rb:45:in `save!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:51:in `create!'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1247:in `record_version_state_after_migrating'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1212:in `block in execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `block in ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `ddl_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1210:in `execute_migration_in_transaction'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1183:in `block in migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `each'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `migrate_without_lock'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `block in migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1298:in `with_advisory_lock'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/pi/.rvm/gems/ruby-2.2.4#gnn/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Edit: Maybe worth saying that rake db:create ran fine.
Here's my database.yml file as well, in case I've missed something there (I'm pretty green with PostgreSQL)
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: gnn_dev
username: gnn
password: Lorem123
host: localhost
port: 5432
I have met the same issue in the middle of development. Have found the reason.
In my case I added a new gem 'imgurapi', that adds 'to_hash' to Array objects
class Array # :nodoc:
# Skipped code
def to_hash # :nodoc:
inject({}) { |hsh, (k,v)| hsh[k] = v ; hsh }
end unless method_defined?(:to_hash)
end
As result the calling the code exec_query(sql, name, binds) in gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:135:in 'exec_insert' converts binds variable from Array to Hash type by the reason, that's good described here https://makandracards.com/makandra/36013-heads-up-ruby-implicitly-converts-a-hash-to-keyword-arguments. As result we have the error, because this conversion is unexpected.
Solution
Find the gem that defines 'to_hash' method for Array and get rid of this definition. Good luck!
Remove [5.0] from the first line .
class CreateAuthors < ActiveRecord::Migration
def change
create_table :authors do |t|
t.string :username
t.timestamps
end
end
end
thanks
Remove [5.0] from the first line
Restart the Server and run rake db:migrate.
May be this will helps you.
I am working on migrating an application from rails 2.3 to rails 3.1, most of the things are working but i am getting this error which i am not sure about. The error is
ActiveRecord::UnknownAttributeError: unknown attribute: package_id
Here is the complete error log
**
ActiveRecord::UnknownAttributeError: unknown attribute: package_id
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:1764:in `block in assign_attributes'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:1758:in `each'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/base.rb:1758:in `assign_attributes'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/persistence.rb:162:in `block in update_attributes'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/connection_adapters/abstract/database_statements.rb:194:in `transaction'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/transactions.rb:208:in `transaction'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/persistence.rb:161:in `update_attributes'
from /Users/tested/Desktop/RailsDevelopement/branch/app/models/package.rb:1131:in `block in void'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/associations/collection_proxy.rb:97:in `each'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/activerecord-3.1.12/lib/active_record/associations/collection_proxy.rb:97:in `method_missing'
from /Users/tested/Desktop/RailsDevelopement/branch/app/models/package.rb:1130:in `void'
from (irb):4
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/railties-3.1.12/lib/rails/commands/console.rb:45:in `start'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/railties-3.1.12/lib/rails/commands/console.rb:8:in `start'
from /Users/tested/.rvm/gems/ruby-1.9.3-p484/gems/railties-3.1.12/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>
**
Any help on this will be appreciated, Thanks.
I'm working through the Hartl ruby on rails tutorial (section 2.2), and I'm having trouble migrating the database. Everything seemed to be working, and then I ran rails generate scaffold User name:string email:string Afterwards I tried to run bundle exec rake db:migrate and got the below error message:
$ bundle exec rake db:migrate
== 20141125234257 CreateUsers: migrating ======================================
-- create_table(:users)
-> 0.0079s
== 20141125234257 CreateUsers: migrated (0.0080s) =============================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (1 for 0)/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
ArgumentError: wrong number of arguments (1 for 0)
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.1.4#rails4/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I've tried going back to an earlier commit and running everything again but I get the same error message. Are there any more files that I should add that can help with this?
I just ran into this as well. This is due to ActiveRecord 4.2.0.beta4 passing a parameter to Arel::Nodes::BindParam.new. Arel 6.0.0 was just released today. In this version, BindParam does not accept any parameters in it's initalizer.
ActiveRecord has already fixed this on the master branch. Until beta5 is released you'll need to lock your Gemfile to gem 'arel', '6.0.0.beta2'.
with above solution of changing gemfile.
gem 'arel', '6.0.0.beta2'
I got below error message.
You have requested:arel = 6.0.0.beta2
The bundle currently has arel locked at 6.0.0.
Try running `bundle update arel`
After
bundle update arel
it worked
I've solved this with
rake db:reset
After that
rake db:migrate
worked.
I am getting this issue while destroying an object.
NoMethodError: undefined method `substitute_at' for nil:NilClass
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/persistence.rb:135:in `destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/locking/optimistic.rb:103:in `destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/callbacks.rb:254:in `block in destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:480:in `_run__348799253__destroy__466331341__callbacks'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_destroy_callbacks'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/callbacks.rb:254:in `destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:254:in `block in destroy'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/activerecord-3.2.11/lib/active_record/transactions.rb:254:in `destroy'
from (irb):1
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p194#clu2/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
I have fixed the issue, My app's one of association name was connection which is reserved word in active record gem:
See line #135
https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/persistence.rb
I changed the association name from connection to something else and everything is fine now.
I have find It is a rails issue https://github.com/rails/rails/pull/9371. I think it is fixed now. You can update you rails
I am using ruby 1.8.7 and rails 2.3.5 and I am getting this weird message "Can't dup NilClass" when I try to run the code below
rr = Node.find(params[:id])
puts rr.inspect
rr.destroy
The application prints out the correct information about the node, when I try to do the exact same thing in script/console it works fine!!! I have no clue what is going on ..
I upgraded my application to rails 2.3.8 but no luck what so ever :(
Please help,
Edit:
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2184:in `dup'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2184:in `scoped_methods'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2188:in `current_scoped_methods'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:2178:in `scope'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1543:in `find_every'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1505:in `find_initial'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:613:in `find'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/has_one_association.rb:80:in `find_target'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:239:in `load_target'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations/association_proxy.rb:112:in `reload'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1250:in `acl'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1460:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/associations.rb:1460:in `has_one_dependent_destroy_for_acl'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in `evaluate_method'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in `call'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:93:in `run'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:92:in `run'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:276:in `run_callbacks'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:344:in `callback'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/callbacks.rb:336:in `destroy_without_transactions'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:229:in `with_transaction_returning_status'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:182:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/transactions.rb:192:in `destroy'
/home/wael/public_html/app/models/node.rb:355:in `destroy'
Wa'el
Is it possibly somehow confusing your Node class with this one?
http://apidock.com/ruby/REXML/Node