I purposely made a mistake in my migration file to show the kind of error i get.
我故意在我的迁移文件中犯了一个错误,以显示我得到的错误。
== 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)
Shouldn't my error message look like this instead?
我的错误信息不应该像这样吗?
== 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'
It is really depressing to see that long error message lol. I have a feeling maybe i did not install rails correctly. Please guide.
看到那个长错误信息lol真是令人沮丧。我有一种感觉,也许我没有正确安装导轨。请指导。
2 个解决方案
#1
2
What you are seeing is called a stack trace. For all but the simplest of errors, it can be used to track down just where the issue is. There's nothing wrong with your installation, this is useful information!
你所看到的被称为堆栈跟踪。对于除最简单的错误之外的所有错误,它可以用于追踪问题的位置。您的安装没有任何问题,这是有用的信息!
As you can see, in the full error, about 8 lines in, it tells you your file, and what line it was on.
正如您所看到的,在完整错误中,大约有8行,它会告诉您文件以及它所在的行。
/Users/my/Desktop/Sites/simple_cms/db/migrate/20150321034322_alter_users.rb:6:in `up'
/Users/my/Desktop/Sites/simple_cms/db/migrate/20150321034322_alter_users.rb:6:in`up'
If the error wasn't on purpose, you'd be grateful for that little bit of information to help you track it down!
如果错误不是故意的,那么您可以感谢一点点信息来帮助您追踪它!
#2
1
This is saying that your schema for table admin_users has no column named "broken"
这就是说表admin_users的模式没有名为“broken”的列
No such column: admin_users.broken
没有这样的专栏:admin_users.broken
The long output is just a stack trace of the error and is what normally happens.
长输出只是错误的堆栈跟踪,通常会发生。
#1
2
What you are seeing is called a stack trace. For all but the simplest of errors, it can be used to track down just where the issue is. There's nothing wrong with your installation, this is useful information!
你所看到的被称为堆栈跟踪。对于除最简单的错误之外的所有错误,它可以用于追踪问题的位置。您的安装没有任何问题,这是有用的信息!
As you can see, in the full error, about 8 lines in, it tells you your file, and what line it was on.
正如您所看到的,在完整错误中,大约有8行,它会告诉您文件以及它所在的行。
/Users/my/Desktop/Sites/simple_cms/db/migrate/20150321034322_alter_users.rb:6:in `up'
/Users/my/Desktop/Sites/simple_cms/db/migrate/20150321034322_alter_users.rb:6:in`up'
If the error wasn't on purpose, you'd be grateful for that little bit of information to help you track it down!
如果错误不是故意的,那么您可以感谢一点点信息来帮助您追踪它!
#2
1
This is saying that your schema for table admin_users has no column named "broken"
这就是说表admin_users的模式没有名为“broken”的列
No such column: admin_users.broken
没有这样的专栏:admin_users.broken
The long output is just a stack trace of the error and is what normally happens.
长输出只是错误的堆栈跟踪,通常会发生。