我故意在我的迁移文件中犯了一个错误,以显示我得到的错误。
== 20150321034322 AlterUsers: migrating =======================================
-- rename_table("users", "admin_users")
-> 0.0023s
-- add_column("admin_users", "username", :string, {:limit=>25, :after=>"email"})
-> 0.0198s
-- change_column("admin_users", "email", :string, {:limit=>100})
-> 0.0162s
-- rename_column("admin_users", "broken", "hashed_password")
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
No such column: admin_users.broken/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:483:in `column_for'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:759:in `rename_column_sql'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:521:in `rename_column'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:662:in `block in method_missing'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `block in say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:652:in `method_missing'
/Users/my/Desktop/Sites/simple_cms/db/migrate/20150321034322_alter_users.rb:6:in `up'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:609:in `exec_migration'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:590:in `block (2 levels) in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:589:in `block in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:588:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:765:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:995:in `block in execute_migration_in_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:1043:in `ddl_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:994:in `execute_migration_in_transaction'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:956:in `block in migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:952:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:820:in `up'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:798:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/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)
我的错误信息不应该是这样的吗?
== 20150321034322 AlterUsers: migrating =======================================
-- rename_table("users", "admin_users")
-> 0.0023s
-- add_column("admin_users", "username", :string, {:limit=>25, :after=>"email"})
-> 0.0198s
-- change_column("admin_users", "email", :string, {:limit=>100})
-> 0.0162s
-- rename_column("admin_users", "broken", "hashed_password")
rake aborted!
StandardError: An error has occurred, all later migrations canceled:
No such column: admin_users.broken/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract_adapter.rb:483:in `column_for'
看到那个长错误信息lol真是令人沮丧。我有一种感觉,也许我没有正确安装导轨。请指导。
答案 0 :(得分:2)
您所看到的内容称为stack trace。对于除最简单的错误之外的所有错误,它可以用于追踪问题的位置。您的安装没有任何问题,这是有用的信息!
正如您所看到的,在完整错误中,大约有8行,它会告诉您文件以及它所在的行。
/Users/my/Desktop/Sites/simple_cms/db/migrate/20150321034322_alter_users.rb:6:in'up up&#39;
如果错误不是故意的,那么您可以感谢一点点信息来帮助您追踪它!
答案 1 :(得分:1)
这就是说表admin_users的架构没有名为“broken”的列
No such column: admin_users.broken
长输出只是错误的堆栈跟踪,并且正常发生。