Resetting & reseeding DB using rake task - ruby-on-rails

Using the code below to reset & reseed the DB
task init: [:environment, 'db:migrate:reset', 'db:seed']
db:seed creates a few users & few objects. It also updates role for few users.
db:seed throws following error NoMethodError: undefined method 'role' for User.
There is a migration file which adds role column to User table.
Unable to resolve this. Tries to write separate task for db:seed. Tried following
task init: [:environment, 'db:migrate:reset', 'db:seed'] do
Rake::Task['db:seed'].invoke
end
Same error as before. Why is column from migration file isn't loaded for db:seed or I am missing something here?
Error log:
NoMethodError: undefined method `role' for #<User:0x00007fd5ecb239e0>
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activemodel-6.0.3.2/lib/active_model/attribute_methods.rb:432:in `method_missing'
/Users/Desktop/rails_app/app/models/user.rb:17:in `update_role'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:428:in `block in make_lambda'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `catch'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `block in default_terminator'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:201:in `block in halting'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `block in invoke_before'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `each'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `invoke_before'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:134:in `run_callbacks'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:825:in `_run_validation_callbacks'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activemodel-6.0.3.2/lib/active_model/validations/callbacks.rb:117:in `run_validations!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activemodel-6.0.3.2/lib/active_model/validations.rb:337:in `valid?'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/validations.rb:68:in `valid?'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/validations.rb:84:in `perform_validations'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/validations.rb:53:in `save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:318:in `block in save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:212:in `transaction'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/transactions.rb:318:in `save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/suppressor.rb:48:in `save!'
/Users/Desktop/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/persistence.rb:55:in `create!'
/Users/Desktop/rails_app/app/services/init_data:6:in `process'
/Users/Desktop/rails_app/db/seeds.rb:3:in `<main>'

Using db:reset solved the issue. i.e.
task init: [:environment, 'db:reset']
db:reset executes db:drop, db:setup.
db:setup executes db:schema:load whereas db:migrate:reset executes db:migrate. And db:schema:load is faster than db:migrate.
Not sure why db:migrate causes the issue.
As Sergio suggested stale cache could be the cause. And his suggestion in the comments User.reset_column_information loads all the columns.

Related

NoMethodError: undefined method `value_for_database' for #<Array> (Rails 5)

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.

Rails Executing migration ArgumentError

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

Can't migrate database after scaffold. Section 2.2 Ruby on Rails Tutorial Michael Hartl

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.

SocketError: getaddrinfo while running heroku run rake db:seed on a Heroku App-Rails4

I am using Rails4 and ruby2.0.0. I pushed my app on Heroku & I m getting this error when I run heroku run rake db:seed
Running rake db:seed attached to terminal... up, run.6298
Rendered devise/mailer/confirmation_instructions.html.erb (1.8ms)
Sent mail to xyz#gmail.com (29.3ms) rake aborted! SocketError:
getaddrinfo: Temporary failure in name resolution
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in deliver!'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:2129:in
do_delivery'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:232:in
block in deliver'
/app/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.0.1/lib/action_mailer/base.rb:456:in
block in deliver_mail'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/notifications.rb:159:in
block in instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/notifications/instrumenter.rb:20:in
instrument'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/notifications.rb:159:in
instrument'
/app/vendor/bundle/ruby/2.0.0/gems/actionmailer-4.0.1/lib/action_mailer/base.rb:454:in
deliver_mail'
/app/vendor/bundle/ruby/2.0.0/gems/mail-2.5.4/lib/mail/message.rb:232:in
deliver'
/app/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/models/authenticatable.rb:173:in
send_devise_notification'
/app/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:102:in
send_confirmation_instructions'
/app/vendor/bundle/ruby/2.0.0/gems/devise-3.2.4/lib/devise/models/confirmable.rb:158:in
send_on_create_confirmation_instructions'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:386:in
_run__3822695918417406283__create__callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:80:in
run_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/callbacks.rb:306:in
create_record'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/timestamp.rb:57:in
create_record'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/persistence.rb:477:in
create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/callbacks.rb:302:in
block in create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:383:in
_run__3822695918417406283__save__callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/callbacks.rb:80:in
run_callbacks'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/callbacks.rb:302:in
create_or_update'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/persistence.rb:106:in
save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/validations.rb:51:in
save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/attribute_methods/dirty.rb:32:in
save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:270:in block (2 levels) in save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:326:inblock in with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
block in transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in
within_new_transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in
transaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:209:intransaction'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:323:in with_transaction_returning_status'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:270:inblock in save'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:281:in rollback_active_record_state!'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:269:insave' /app/db/seeds.rb:8:in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:inload'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in block in load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:inload_dependency'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in load'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/engine.rb:540:in
load_seed'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/tasks/database_tasks.rb:154:in
load_seed'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.1/lib/active_record/railties/databases.rake:181:in
block (2 levels) in ' Tasks: TOP => db:seed (See full
trace by running task with --trace)
You are creating devise users in your seed file. Devise automatically sends some emails E.g. email_confirmation.
So you have to set up a proper ActionMailer for production Environment. You might be using an another heroku service for that. E.g mailgun
You can also bypass devise email_confirmation in your seed file.

cannot rollback migration with rake db:rollback

I guess this is another reason I should be backing up my work with GitHub, but alas, I have not been.
The migration I want to rollback is this:
class AddAssociationToTables < ActiveRecord::Migration
def change
add_column :articles, :user, :belongs_to
end
end
Which obviously isn't well formed because it seems to have totally removed my article table from the database.
I tried rake db:rollback:status and there is nothing 'missing' or anything.
I'm gonna skip copy-pasting the entire trace.
I tried to make a counteracting migration and run that. This is what I wrote:
class RemoveAssociationFromArticle < ActiveRecord::Migration
def change
remove_column :articles, :user, :belongs_to
end
end
But when I tried to run rake db:migrate with this I got what looks like the same error.
EDIT ok here's the whole trace for the rollback first, and then the migrate attempt
== AddAssociationToTables: reverting =========================================
-- remove_column(:articles, :user, :belongs_to)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `to_sym' for nil:NilClass/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:215:in `column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:545:in `block (2 levels) in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `block in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:184:in `create_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:535:in `copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:528:in `move_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:521:in `block in alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:520:in `alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:463:in `remove_column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:625:in `block in method_missing'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `block in say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:617:in `method_missing'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:462:in `block in revert'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:461:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:461:in `revert'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:569:in `exec_migration'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:554:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:553:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:709:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:209:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:920:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:771:in `down'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:857:in `move'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:753:in `rollback'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/railties/databases.rake:126:in `block (2 levels) in <top (required)>'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:rollback
(See full trace by running task with --trace)
== RemoveAssociationFromArticle: migrating ===================================
-- remove_column(:articles, :user, :belongs_to)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `to_sym' for nil:NilClass/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:215:in `column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:545:in `block (2 levels) in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:538:in `block in copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:184:in `create_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:535:in `copy_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:528:in `move_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:521:in `block in alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:520:in `alter_table'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:463:in `remove_column'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:625:in `block in method_missing'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `block in say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:597:in `say_with_time'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:617:in `method_missing'
/home/macs/code/my_apps/rails_apps/satisfactory/dec1/whatis/db/migrate/20131202144933_remove_association_from_article.rb:3:in `change'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:571:in `exec_migration'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:555:in `block (2 levels) in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:554:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:553:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:709:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:959:in `block in execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `block in ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/transactions.rb:209:in `transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:1005:in `ddl_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:958:in `execute_migration_in_transaction'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:920:in `block in migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `each'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:916:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:764:in `up'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/migration.rb:742:in `migrate'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/activerecord-4.0.1/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
/home/macs/.rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
The third parameter should be the type of column.
The correct syntax is:
add_column :articles, :user_id, :integer
The :belongs_to parameter may causing conflict with ActiveRecord methods!
If it did not migrate properly in the first place, don't worry about rolling back. Just fix the migration and try to migrate again.
Your migration should be:
add_column :articles, :user, :references
The belongs_to is for in the model class, and not in the migration. If it gets to a point where you can't do anything, you can always recreate the database to start fresh (and lose all data).
$ rake db:drop db:create db:migrate
Start using version control, and read through all of this slowly and carefully at some point in life http://guides.rubyonrails.org/migrations.html

Resources