My model insertion is in Shift_jis (Japanese),
The file has #encoding: shift_jis at the begining, then I do,
User.create({ user_name: "管理者" })
The character is shift_jis encoded!
My database is oracle (using oracle_enhanced ruby gems), which is also shift_jis encoded.
My OS is Windows-10 English but with Japanese as primary language (but I think default encoding is unicode?).
However, during the insertion, there's an error of:
Encoding::UndefinedConversionError: U+7BA1 to WINDOWS-1252 in conversion from Shift_JIS to UTF-8 to WINDOWS-1252
So here's the question:
I can probably understand that ActiveRecord internally converts shift_jis to utf-8, but how to let it insert into database as shift_jis?
Why there is a conversion to WINDOWS-1252?
Is there a solution for that? I tried to use utf-8 encoding for ActiveRecord (database is shift_jis which is strictly not changable), and I added encoding: sjis in database.yml, however, ActiveRecord still insert the data ase utf-8 without conversion. So the database returns error (character too long, it's understandable that utf-8 has longer bytes than shift_jis encoding).
Frankly I don't understand why ActiveRecord started to embrace utf-8 but dropped all supports for non-utf8 encoding. Database charset migration is too sensible for managers and they can't afford any such changes but it's hell for programmers to upgrade from rails legacy (where everything works) to latest version of rails (where such simple thing breaks and solution is hard to find).
As requested (I just changed my encoding to utf-8, but error is same, there's just not shift-jis to utf-8 conversion, but still error for utf-8 to windows-1252):
Path information removed because of 300000 characters limitation.
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
Encoding::UndefinedConversionError: U+7BA1 to WINDOWS-1252 in conversion from UTF-8 to WINDOWS-1252: INSERT INTO "USERS" ("ID", "LOGIN", "HASHED_PASSWORD", "SALT", "USER_NAME", "START_DATE", "END_DATE", "MAIL", "MAIL_NOTIFICATION", "CREATED_AT", "UPDATED_AT") VALUES (:a1, :a2, :a3, :a4, :a5, :a6, :a7, :a8, :a9, :a10, :a11)
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/bindtype.rb:121:in `encode'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/bindtype.rb:121:in `create'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/cursor.rb:504:in `make_bind_object'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/cursor.rb:99:in `bind_param'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:143:in `bind_param'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:139:in `block (2 levels) in exec_insert'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `each'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `each_with_index'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `block in exec_insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1353:in `log'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:121:in `exec_insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:108:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/relation.rb:64:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:524:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/counter_cache.rb:139:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/locking/optimistic.rb:75:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/dirty.rb:133:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:306:in `block in _create_record'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_create_callbacks'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:306:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/timestamp.rb:57:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:504:in `create_or_update'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_save_callbacks'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:302:in `create_or_update'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:142:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/validations.rb:43:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:291:in `block in save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:220:in `transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:291:in `save!'
/db/migrate/20081113061046_load_users_data.rb:43:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:571:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:611:in `exec_migration'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/2.2.0/benchmark.rb:288:in `measure'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:591:in `block in migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:590:in `migrate'
C:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:1046:in `ddl_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:959:in `block in migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `each'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:823:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:801:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `call'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/2.2.0/monitor.rb:211:in `mon_synchronize'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
bin/rake:4:in `<main>'
ActiveRecord::StatementInvalid: Encoding::UndefinedConversionError: U+7BA1 to WINDOWS-1252 in conversion from UTF-8 to WINDOWS-1252: INSERT INTO "USERS" ("ID", "LOGIN", "HASHED_PASSWORD", "SALT", "USER_NAME", "START_DATE", "END_DATE", "MAIL", "MAIL_NOTIFICATION", "CREATED_AT", "UPDATED_AT") VALUES (:a1, :a2, :a3, :a4, :a5, :a6, :a7, :a8, :a9, :a10, :a11)
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/bindtype.rb:121:in `encode'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/bindtype.rb:121:in `create'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/cursor.rb:504:in `make_bind_object'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/cursor.rb:99:in `bind_param'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:143:in `bind_param'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:139:in `block (2 levels) in exec_insert'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `each'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `each_with_index'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `block in exec_insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1353:in `log'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:121:in `exec_insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:108:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/relation.rb:64:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:524:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/counter_cache.rb:139:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/locking/optimistic.rb:75:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/dirty.rb:133:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:306:in `block in _create_record'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_create_callbacks'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:306:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/timestamp.rb:57:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:504:in `create_or_update'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_save_callbacks'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:302:in `create_or_update'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:142:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/validations.rb:43:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:291:in `block in save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:220:in `transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:291:in `save!'
/db/migrate/20081113061046_load_users_data.rb:43:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:571:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:611:in `exec_migration'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/2.2.0/benchmark.rb:288:in `measure'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:591:in `block in migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:590:in `migrate'
C:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:1046:in `ddl_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:959:in `block in migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `each'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:823:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:801:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `call'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/2.2.0/monitor.rb:211:in `mon_synchronize'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
bin/rake:4:in `<main>'
Encoding::UndefinedConversionError: U+7BA1 to WINDOWS-1252 in conversion from UTF-8 to WINDOWS-1252
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/bindtype.rb:121:in `encode'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/bindtype.rb:121:in `create'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/cursor.rb:504:in `make_bind_object'
/gems/2.2.0/gems/ruby-oci8-2.2.1-x86-mingw32/lib/oci8/cursor.rb:99:in `bind_param'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:143:in `bind_param'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:139:in `block (2 levels) in exec_insert'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `each'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `each_with_index'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:132:in `block in exec_insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1353:in `log'
/gems/2.2.0/gems/activerecord-oracle_enhanced-adapter-1.6.7/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:121:in `exec_insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:108:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/relation.rb:64:in `insert'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:524:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/counter_cache.rb:139:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/locking/optimistic.rb:75:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/dirty.rb:133:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:306:in `block in _create_record'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_create_callbacks'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:306:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/timestamp.rb:57:in `_create_record'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:504:in `create_or_update'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/callbacks.rb:778:in `_run_save_callbacks'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/callbacks.rb:302:in `create_or_update'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/persistence.rb:142:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/validations.rb:43:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:291:in `block in save!'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:220:in `transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/transactions.rb:291:in `save!'
/db/migrate/20081113061046_load_users_data.rb:43:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:571:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:611:in `exec_migration'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/2.2.0/benchmark.rb:288:in `measure'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:591:in `block in migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:590:in `migrate'
C:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:1046:in `ddl_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:959:in `block in migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `each'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:955:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:823:in `up'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/migration.rb:801:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `call'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/2.2.0/monitor.rb:211:in `mon_synchronize'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/gems/2.2.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
bin/rake:4:in `<main>'
Tasks: TOP => db:migrate
My solution that works is:
in boot.rb, add this line of code:
ENV['NLS_LANG'] ||= 'AMERICAN_AMERICA.JA16SJIS'
This will tell activerecord or oracle_enhanced gem to save in database as SJIS encoding.
However, I have to say that the ActiveRecord::Fixtures still doesn't work. Fixtures still tries to insert into database as utf-8.
Look at my another question that still doesn't have an answer yet.
Fixtures: How to load utf-8 characters and convert to non utf-8 and save into database?
Final edit: fixtures also solved.
I'm a newbie in ruby.Today I install foreman from source.
When I run command RAILS_ENV=production bundle exec rake db:seed assets:precompile locale:pack, it generates the following error message.
I don't think there is something wrong with the code, because I get the code
from git with command git clone https://github.com/theforeman/foreman.git -b 1.7-stable
After I get the error message,I do the following things: edit file ROOTDIR/config/application.rb, add the following lines, but it also get the same error message
config.i18n.enforce_available_locales = false
config.i18n.available_locales = ["zh-CN"]
#config.i18n.default_locales = :'zh-CN'
My ruby verision is ruby-2.0.0-p451
Looking forward to anyone get me out of the fall. Thanks.
########## error message ############
rake aborted!
I18n::InvalidLocale: :en is not a valid locale
/root/foreman/vendor/ruby/2.0.0/gems/i18n-0.7.0/lib/i18n.rb:284:in `enforce_available_locales!'
/root/foreman/vendor/ruby/2.0.0/gems/i18n-0.7.0/lib/i18n.rb:151:in `translate'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/naming.rb:57:in `human'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/errors.rb:346:in `generate_message'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/errors.rb:359:in `normalize_message'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/errors.rb:234:in `add'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations/inclusion.rb:19:in `validate_each'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validator.rb:153:in `block in validate'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validator.rb:150:in `each'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validator.rb:150:in `validate'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:310:in `_callback_before_105'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:550:in `_run__2320509037395656532__validate__260782132788772307__callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_validate_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations.rb:228:in `run_validations!'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations/callbacks.rb:53:in `block in run_validations!'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:425:in `_run__2320509037395656532__validation__260782132788772307__callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_validation_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations.rb:195:in `valid?'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:69:in `valid?'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:77:in `perform_validations'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:50:in `save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/attribute_methods/dirty.rb:22:in `save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:259:in `block in save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:258:in `save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/persistence.rb:217:in `block in update_attributes'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/persistence.rb:215:in `update_attributes'
/root/foreman/app/models/setting.rb:177:in `block in create_existing'
/root/foreman/app/models/setting.rb:184:in `bypass_readonly'
/root/foreman/app/models/setting.rb:174:in `create_existing'
/root/foreman/app/models/setting.rb:167:in `create!'
/root/foreman/app/models/setting/general.rb:29:in `block (2 levels) in load_defaults'
/root/foreman/app/models/setting/general.rb:29:in `each'
/root/foreman/app/models/setting/general.rb:29:in `block in load_defaults'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
/root/foreman/app/models/setting/general.rb:13:in `load_defaults'
/root/foreman/config/initializers/foreman.rb:20:in `each'
/root/foreman/config/initializers/foreman.rb:20:in `<top (required)>'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `block in load'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:592:in `each'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:592:in `block in <class:Engine>'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `instance_exec'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `run'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:55:in `block in run_initializers'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `each'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `run_initializers'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:136:in `initialize!'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in `method_missing'
/root/foreman/config/environment.rb:5:in `<top (required)>'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `block in require'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:103:in `require_environment!'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/railties/databases.rake:346:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:abort_if_pending_migrations => environment
change
config.i18n.available_locales = ["zh-CN"]
to
config.i18n.available_locales = ["zh-CN",:en]
I'm having a strange problem executing rake db:migrate
== 20141127213559 CreateMovies: migrating =====================================
-- create_table(:movies)
-> 0.0033s
== 20141127213559 CreateMovies: migrated (0.0034s) ============================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (1 for 0)
ArgumentError: wrong number of arguments (1 for 0)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
What I did was:
rails generate model Movie
And then edit the migration CreateMovies
class CreateMovies < ActiveRecord::Migration
def up
#drop_table :movies
create_table :movies do |t|
t.string :title
t.string :rating
t.text :description
t.datetime :release_date
# Add fields that let Rails automatically keep track
# of when movies are added or modified:
t.timestamps
end
end
def down
drop_table :movies
end
end
This is the output of executing the command with --trace
[fran#arch rottenpotatoes]$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== 20141127213559 CreateMovies: migrating =====================================
-- create_table(:movies)
-> 0.0039s
== 20141127213559 CreateMovies: migrated (0.0041s) ============================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (1 for 0)/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `call'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:165:in `invoke'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:156:in `invoke_task'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:121:in `run_with_threads'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:106:in `top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:84:in `block in run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:182:in `standard_exception_handling'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:79:in `run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/bin/rake:33:in `<top (required)>'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `load'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `<main>'
ArgumentError: wrong number of arguments (1 for 0)
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `call'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:165:in `invoke'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:156:in `invoke_task'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:121:in `run_with_threads'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:106:in `top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:84:in `block in run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:182:in `standard_exception_handling'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:79:in `run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/bin/rake:33:in `<top (required)>'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `load'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
Any help would be really appreciated. Thanks.
If you are using Rails 4.2.0.beta4, ActiveRecord will require arel gem. Add the following to your gem file
gem 'arel', '6.0.0.beta2'
and run
bundle install
You may get 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`
then
bundle update arel
Now you should able to run migration.
Here you may find similar and explanatory answer: Can't migrate database after scaffold. Section 2.2 Ruby on Rails Tutorial Michael Hartl
Maybe you should execute this after create movies table:
generate migration AddFieldsToMovies newfield:type
This generates the correct migration, see this:
http://edgeguides.rubyonrails.org/active_record_migrations.html#changing-tables
When I run a rake task that involves a model with gmaps4rails enabled I get this error, and if I comment the model so it's not acts_as_gmappable it completes properly.
enter code here
troy$ rake populate:scans --trace
** Invoke populate:scans (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute populate:scans
http://goo.gl/fb/977ze
Sat, 16 Jul 2011 19:43:59 GMT
47.676506
-122.121872
91df0f32209c5212XXXXXXXXXXXXXXX
rake aborted!
undefined method `gmaps' for #<Scan:0x000001051fb9a8>
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.9/lib/active_model/attribute_methods.rb:392:in `method_missing'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/attribute_methods.rb:46:in `method_missing'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/gmaps4rails-0.9.1/lib/gmaps4rails/acts_as_gmappable.rb:12:in `process_geocoding'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:415:in `_run_validate_callbacks'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.9/lib/active_model/validations.rb:212:in `run_validations!'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.9/lib/active_model/validations/callbacks.rb:67:in `block in run_validations!'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:414:in `_run_validation_callbacks'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.9/lib/active_model/validations/callbacks.rb:67:in `run_validations!'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.9/lib/active_model/validations.rb:179:in `valid?'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/validations.rb:55:in `valid?'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/validations.rb:75:in `perform_validations'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/validations.rb:43:in `save'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/attribute_methods/dirty.rb:21:in `save'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/transactions.rb:240:in `block (2 levels) in save'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/transactions.rb:207:in `transaction'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/transactions.rb:240:in `block in save'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.9/lib/active_record/transactions.rb:239:in `save'
/Users/troy/Documents/projects/qrbrowser/lib/tasks/populate.rake:42:in `block (3 levels) in <top (required)>'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.5.0/lib/nokogiri/xml/node_set.rb:239:in `block in each'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.5.0/lib/nokogiri/xml/node_set.rb:238:in `upto'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.5.0/lib/nokogiri/xml/node_set.rb:238:in `each'
/Users/troy/Documents/projects/qrbrowser/lib/tasks/populate.rake:23:in `block (2 levels) in <top (required)>'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/troy/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/Users/troy/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
Tasks: TOP => populate:scans
Solution 1:
acts_as_gmappable :process_geocoding => false
Solution 2:
When you're creating an instance of your model, do:
#scan.instance_eval do
def process_geocoding
true
end
end
I am upgrading my app from Rails 2.2 to 2.3.5 and I am seeing the following error while using '<<' for saving a has_many relationship.
Eg: Breaks test
ev = UserEvent.new
# model specific code here
self.user_events << ev
Eg: Works
ev = UserEvent.new
# model specific code here
ev.user_id = self.id
ev.save!
This worked fine with Rails 2.2.
The issue that I see is similar to http://www.ruby-forum.com/topic/188598 (How can I track if a plugin or gem is causing this issue)
Full error log:
wrong number of arguments (1 for 0)
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb:61:in `save'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb:61:in `insert_record'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:145:in `send'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:145:in `send'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/autosave_association.rb:298:in `save_collection_association'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:369:in `method_missing_without_paginate'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `method_missing'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `each'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `send'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `method_missing'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:369:in `method_missing_without_paginate'
/home/rails/.cruise/projects/rails235/work/vendor/plugins/will_paginate/lib/will_paginate/finder.rb:167:in `method_missing'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/autosave_association.rb:289:in `save_collection_association'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/autosave_association.rb:168:in `autosave_associated_records_for_user_events'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:180:in `evaluate_method'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:180:in `evaluate_method'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:180:in `instance_eval'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:180:in `evaluate_method'
/home/rails/.cruise/projects/rails235/work/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:554:in `call'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:93:in `run'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `each'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `send'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:92:in `run'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activesupport/lib/active_support/callbacks.rb:276:in `run_callbacks'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/callbacks.rb:344:in `callback'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/callbacks.rb:267:in `create'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/base.rb:2874:in `create_or_update_without_callbacks'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/callbacks.rb:250:in `create_or_update'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/base.rb:2555:in `save_without_validation!'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/validations.rb:1088:in `save_without_dirty!'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/dirty.rb:87:in `save_without_transactions!'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/transactions.rb:182:in `transaction'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!'
./db/migrate//294_add_system_user.rb:43:in `up_without_benchmarks'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `send'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/opt/ruby-enterprise/lib/ruby/1.8/benchmark.rb:293:in `measure'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:282:in `migrate'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `__send__'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:365:in `migrate'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:486:in `migrate'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:562:in `call'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:562:in `ddl_transaction'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:485:in `migrate'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `each'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:472:in `migrate'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:400:in `up'
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/migration.rb:383:in `migrate'
/home/rails/.cruise/projects/rails235/work/vendor/rails/railties/lib/tasks/databases.rake:116
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:636:in `call'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:636:in `execute'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:631:in `each'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:631:in `execute'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/ruby-enterprise/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:583:in `invoke'
/home/rails/.cruise/projects/rails235/work/lib/tasks/cruisecontrol.rake:23
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:636:in `call'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:636:in `execute'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:631:in `each'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:631:in `execute'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/ruby-enterprise/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:583:in `invoke'
/opt/cruisecontrolrb-1.3.0/tasks/cc_build.rake:5:in `invoke_rake_task'
/opt/cruisecontrolrb-1.3.0/tasks/cc_build.rake:35
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:636:in `call'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:636:in `execute'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:631:in `each'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:631:in `execute'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/ruby-enterprise/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:583:in `invoke'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:2047:in `invoke_task'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:2025:in `top_level'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:2025:in `each'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:2025:in `top_level'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:2064:in `standard_exception_handling'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:2019:in `top_level'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:1997:in `run'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:2064:in `standard_exception_handling'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/rake-0.8.6/lib/rake.rb:1994:in `run'
-e:1
Any help is tracking this down is really appreciated :)
I don't see anything wrong from your code, but in the error it looks like you're using a pagination plugin which may be your culprit.
/home/rails/.cruise/projects/rails235/work/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:369:in `method_missing_without_paginate'