I just reinstalled my Ubuntu, so I installed Ribu and Rails. All was going pretty well, but when I tried to make a model (database table) a couple errors showed up.
Here's the error without trace:
cdr#ubuntu:~/pro$ rake db:migrate
== CreateMonsters: migrating =================================================
-- create_table(:monsters)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `straing' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x000000023cae90>
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:4:in `block in change'
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
This is with trace:
cdr#ubuntu:~/pro$ 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
== CreateMonsters: migrating =================================================
-- create_table(:monsters)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `straing' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x00000003f4c3d0>
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:4:in `block in change'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:466:in `block in method_missing'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `block in say_with_time'
/usr/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:438:in `say_with_time'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:458:in `method_missing'
/home/cdr/pro/db/migrate/20121201195505_create_monsters.rb:3:in `change'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:407:in `block (2 levels) in migrate'
/usr/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:407:in `block in migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:389:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:528:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `call'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:208:in `transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:775:in `ddl_transaction'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:719:in `block in migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:700:in `each'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:700:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:570:in `up'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/migration.rb:551:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/usr/lib/ruby/gems/1.9.1/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
This is the migration:
class CreateMonsters < ActiveRecord::Migration
def change
create_table :monsters do |t|
t.straing :name
t.text :description
t.timestamps
end
end
end
t.straing? should that be t.string
the error you posted (snippet below)
An error has occurred, this and all later migrations canceled:
undefined method `straing'
is pointing you in the direction of what's wrong
Related
I am unable to create tables (i.e. run db:migrate successfully) in Rail 6 on Windows 7.
Just in case I completely reinstalled rails by Installing Ruby 2.6 development pack and doing a 'gem install rails' which for me installed Rails 6.0.3.1
I created a new project and the first thing did was generate a 'Customer' model after which I ran the db:migrate command immediately after it failed saying the 'wrong number of arguments were given'. See below.
C:\Apps\rails>cd cmdb
C:\Apps\rails\cmdb>rails generate model Customer string:name
invoke active_record
create db/migrate/20200525080817_create_customers.rb
create app/models/customer.rb
invoke test_unit
create test/models/customer_test.rb
create test/fixtures/customers.yml
C:\Apps\rails\cmdb>rails db:migrate
== 20200525080817 CreateCustomers: migrating ==================================
-- create_table(:customers)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Caused by:
ArgumentError: wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
The migration.rb was generated and is shown below:-
class CreateCustomers < ActiveRecord::Migration[6.0]
def change
create_table :customers do |t|
t.name :string
t.timestamps
end
end
end
The re-run with a full trace is pasted below:-
C:\Apps\rails\cmdb>rails db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:migrate
== 20200525080817 CreateCustomers: migrating ==================================
-- create_table(:customers)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:309:in `create_table'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:890:in `block in method_missing'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `block in say_with_time'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `say_with_time'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:879:in `method_missing'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:828:in `exec_migration'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:811:in `block in migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:810:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in tra
nsaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_
transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in
synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchroniz
e'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transacti
on'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1231:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command.rb:48:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Caused by:
ArgumentError: wrong number of arguments (given 1, expected 0)
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:4:in `block in change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:309:in `create_table'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:890:in `block in method_missing'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `block in say_with_time'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:858:in `say_with_time'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:879:in `method_missing'
C:/Apps/rails/cmdb/db/migrate/20200525080817_create_customers.rb:3:in `change'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:828:in `exec_migration'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
C:/Ruby26-x64/lib/ruby/2.6.0/benchmark.rb:293:in `measure'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:811:in `block in migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:810:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1002:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in tra
nsaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_
transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in
synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchroniz
e'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transacti
on'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/transactions.rb:212:in `transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1361:in `ddl_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1231:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1061:in `up'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/migration.rb:1036:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/command.rb:48:in `invoke'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:migrate
C:\Apps\rails\cmdb>
In case anyone else is wondering why else this could be:
I generated a migration with the same name as my model and started to get TypeError: superclass mismatch for class MyCustomClassName error. Then I renamed the migration class to CreateMyCustomClassNameTable but left its file name the same 20201217095257_my_custom_class_name.rb which produced ArgumentError: wrong number of arguments (given 2, expected 0..1) error. Renaming file to 20201217095257_create_my_custom_class_name_table.rb fixes the problem for me.
You have generated migration wrongly.
The column name comes first and it's data type follows it. Compare following with the command you used.
rails generate model Customer name:string
You can quickly fix it by running
rails destroy model Customer
and then re generate migration using the generate command I shared above.
I recently ran into a similar issue, below is the error that I got:
-- create_table(:workers)
rails aborted!
StandardError: An error has occurred, all later migrations canceled:
wrong number of arguments (given 1, expected 0)
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:9:in `block in change'
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:3:in `change'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/rails:5:in `<top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:10:in `block in <top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:7:in `<top (required)>'
Caused by:
ArgumentError: wrong number of arguments (given 1, expected 0)
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:9:in `block in change'
/home/wint3r/Learn/RubyOnRails/AssetManager/db/migrate/20210516062205_create_workers.rb:3:in `change'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/rails:5:in `<top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:10:in `block in <top (required)>'
/home/wint3r/Learn/RubyOnRails/AssetManager/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
In my case issue occurred because I tried to use t.timestamps for a custom datetime field 'emp_joining_date', I solved it by changing the type from t.timestamps to t.datetime
I am getting an "wrong number of arguments (given 1, expected 0)" error when trying to run rake db:migrate on my psql database. This asker had the same trouble, but locking my Gemfile "to gem 'arel', '6.0.0.beta2'" and using rails version 4.2.0.beta4 hasn't fixed the issue though I am able to bundle and am absolutely using these versions. Any help would be much appreciated!
Here is the full trace
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
== 20161104230329 Createmytable: migrating ==================================
-- create_table(:mytable)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (given 1, expected 0)
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:4:in `block in change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/schema_statements.rb:199:in `create_table'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:655:in `block in method_missing'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `block in say_with_time'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `say_with_time'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:645:in `method_missing'
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:3:in `change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:599:in `exec_migration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:583:in `block (2 levels) in migrate'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:582:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:581:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:758:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:984:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/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.3.0/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.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:248:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:173:in `invoke'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:152:in `invoke_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:117:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:102:in `top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:80:in `block in run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
ArgumentError: wrong number of arguments (given 1, expected 0)
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:4:in `block in change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/schema_statements.rb:199:in `create_table'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:655:in `block in method_missing'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `block in say_with_time'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:625:in `say_with_time'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:645:in `method_missing'
/home/ubuntu/workspace/mydb_api/db/migrate/20161104230329_create_mytable.rb:3:in `change'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:599:in `exec_migration'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:583:in `block (2 levels) in migrate'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:582:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:581:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:758:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:984:in `block in execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/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.3.0/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.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/local/rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:248:in `block in execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:243:in `execute'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:180:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/task.rb:173:in `invoke'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:152:in `invoke_task'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `each'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:108:in `block in top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:117:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:102:in `top_level'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:80:in `block in run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:178:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/lib/rake/application.rb:77:in `run'
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.3.0/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
Here is the file 20161104230329_create_mytable.rb
class CreateTables < ActiveRecord::Migration
def change
create_table :mytable do |t|
t.name :string
t.param1 :integer
t.param2 :integer
t.param3 :integer
t.timestamps null: false
end
end
end
You have the order of the field/field type options of your migration reversed. Should be
class CreateTables < ActiveRecord::Migration
def change
create_table :mytable do |t|
t.string :name
t.integer :param1
t.timestamps
end
end
end
I'm following the RoR Getting Started tutorial. Having created posts, I'm now adding the second model to create comments. However, when I try rake db:migrate I get this:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== CreateComments: migrating =================================================
-- create_table(:comments)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `reference' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x1084a24d8>
/Users/Fryed/rails/blog/db/migrate/20120710225337_create_comments.rb:6:in `change'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:466:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:466:in `method_missing'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `say_with_time'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `say_with_time'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:458:in `method_missing'
/Users/Fryed/rails/blog/db/migrate/20120710225337_create_comments.rb:3:in `change'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `migrate'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `migrate'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:389:in `migrate'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:528:in `__send__'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:528:in `migrate'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:720:in `migrate'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `ddl_transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/transactions.rb:208:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `ddl_transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:719:in `migrate'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `each'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `migrate'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:570:in `up'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/migration.rb:551:in `migrate'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.6/lib/active_record/railties/databases.rake:153
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Library/Ruby/Gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/usr/bin/rake:23:in `load'
/usr/bin/rake:23
Tasks: TOP => db:migrate
I'm running:
Rake 0.9.2.2.
Ruby 1.8.7
Rails 3.2.6
Migrations with references use the references helper, you probably just forgot to put the s in the end.
Find the offending migration db/migrate/20120710225337_create_comments.rb and change from reference to references
I'm new to Rails, and am following the getting started guide on their website.
I'm getting an error when I run $ rake db:migrate in section: http://guides.rubyonrails.org/getting_started.html#generating-a-model
It worked for the first time in section: http://guides.rubyonrails.org/getting_started.html#running-a-migration
So I don't know what is wrong.
When I run $ rake db:migrate
== CreateComments: migrating =================================================
-- create_table(:comments)
rake aborted!
An error has occurred, this and all later migrations canceled:
private method `test' called for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x007f83a27503c8>
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
So I followed the instructions to run it with the --trace argument; I was wondering if anyone has a clue what it means, and what the issue is?
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== CreateComments: migrating =================================================
-- create_table(:comments)
rake aborted!
An error has occurred, this and all later migrations canceled:
private method `test' called for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x007f8bacbba730>
/Users/parnmatt/Sites/test-rails/blog/db/migrate/20120627130542_create_comments.rb:5:in `block in change'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:466:in `block in method_missing'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `block in say_with_time'
/Users/parnmatt/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:438:in `say_with_time'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:458:in `method_missing'
/Users/parnmatt/Sites/test-rails/blog/db/migrate/20120627130542_create_comments.rb:3:in `change'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `block (2 levels) in migrate'
/Users/parnmatt/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:407:in `block in migrate'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:389:in `migrate'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:528:in `migrate'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `call'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/transactions.rb:208:in `transaction'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:775:in `ddl_transaction'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:719:in `block in migrate'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `each'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:700:in `migrate'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:570:in `up'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/migration.rb:551:in `migrate'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.6/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/parnmatt/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `load'
/Users/parnmatt/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate
This is the migration code generated:
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.string :commenter
t.test :body
t.references :post
t.timestamps
end
add_index :comments, :post_id
end
end
Looks like when you ran the generator you said 'test' instead of 'text' for body.
Should have been: $ rails generate model Comment commenter:string body:text post:references
Rake doesn't know what type t.test is...it would have been t.text
I have a trivial Rails migration that is failing when I run rake db:migrate. This is in a development environment using SQLite3. This is the migration:
class RemoveMobileUserIdFromDevices < ActiveRecord::Migration
def up
remove_column :devices, :mobile_user_id
end
def down
add_column :devices, :mobile_user_id, :integer
end
end
I am experiencing the following error when running rake db:migrate:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
== RemoveMobileUserIdFromDevices: migrating ==================================
-- remove_column(:devices, :mobile_user_id)
rake aborted!
An error has occurred, this and all later migrations canceled:
incompatible character encodings: ASCII-8BIT and UTF-8
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:516:in `*'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:516:in `block in copy_table_contents'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/result.rb:20:in `block in each'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/result.rb:20:in `each'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/result.rb:20:in `each'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:514:in `copy_table_contents'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:478:in `copy_table'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:455:in `move_table'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:448:in `block in alter_table'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:447:in `alter_table'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:387:in `block in remove_column'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:386:in `each'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:386:in `remove_column'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:447:in `block in method_missing'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:422:in `block in say_with_time'
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:422:in `say_with_time'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:442:in `method_missing'
/Users/username/[removed]/[removed]/db/migrate/20120127204256_remove_mobile_user_id_from_devices.rb:3:in `up'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:394:in `block (2 levels) in migrate'
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/benchmark.rb:280:in `measure'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:394:in `block in migrate'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:375:in `migrate'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:507:in `migrate'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:687:in `block (2 levels) in migrate'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:742:in `call'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:742:in `block in ddl_transaction'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/transactions.rb:208:in `transaction'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:742:in `ddl_transaction'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:686:in `block in migrate'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:671:in `each'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:671:in `migrate'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:549:in `up'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/migration.rb:530:in `migrate'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/railties/databases.rake:161:in `block (2 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/username/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/username/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/username/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `load'
/Users/username/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate
I'm not sure what the issue could be, as I have previous migrations with similar commands that have executed without issue. So far, I have tried typing the migration file by hand in TextMate (under the presumption that the actual file may have had a bad character encoding). I have also deleted the migration and recreated it via rails g migration RemoveMobileUserIdFromDevices mobile_user_id:integer but have seen no change.