Hello pls help with an unexpected error when I run my rails app. rake db:migrate then there is an error
CreateTodoItems: migrating ================================== -- create_table(:todo_items) rake aborted! StandardError: An error has occurred, this and all later migrations canceled:
undefined method reference' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x007f9d9c981ed0>/Users/chenziwang/odot/db/migrate/20150421184553_create_todo_items.rb:4:in
block in change' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:202:in create_table' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:662:in
block in method_missing' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:632:in block in say_with_time' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:632:in
say_with_time' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:652:in method_missing' /Users/chenziwang/odot/db/migrate/20150421184553_create_todo_items.rb:3:in
change' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:606:in exec_migration' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:590:in
block (2 levels) in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:589:in block in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in
with_connection' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:588:in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:765:in
migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:995:in block in execute_migration_in_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:1041:in
block in ddl_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in block in transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:188:in
within_new_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/transactions.rb:220:in
transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:1041:in ddl_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:994:in
execute_migration_in_transaction' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:956:in block in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:952:in
each' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:952:in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:820:in
up' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/migration.rb:798:in migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/tasks/database_tasks.rb:137:in
migrate' /Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.1/lib/active_record/railties/databases.rake:44:in `block (2 levels) in ' Tasks: TOP => db:migrate (See full trace by running task with --trace)
my migrate files are: class CreateTodoLists < ActiveRecord::Migration def change create_table :todo_lists do |t| t.string :title t.text :description
t.timestamps null: false
end
end end
Another file is class CreateTodoItems < ActiveRecord::Migration def change create_table :todo_items do |t| t.reference :todo_list t.string :content
t.timestamps null: false
end
end end
Aucun commentaire:
Enregistrer un commentaire