在我的应用程序中,当我去时,localhost:3000/users/3
我得到一个
ActiveRecord::RecordNotFound at /users/3
但是,当我进入控制台并u = User.find(3)
看到以下内容时:
> u = User.find(3)
User Load (31.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 3]]
=> #<User id: 3, email: "abc3@test.com", encrypted_password: "$2a$10$x9iFcz1kooaQD1P9zFl/jOqwjC9veK6cCEP6zF/mtTMr...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2012-12-13 19:27:34", updated_at: "2012-12-13 19:27:34", name: "Third User">
即使我没有指定任何不同的数据库,它是否有可能是从不同的数据库中提取的?
对于它的价值,一切都很好,直到我想重置我的数据库并重新运行我的seeds.rb
......所以我最近做了:
rake db:reset
这正是我想要做的,那就是:
$ rake db:reset
-- create_table("roles", {:force=>true})
-> 0.0857s
-- add_index("roles", ["name", "resource_type", "resource_id"], {:name=>"index_roles_on_name_and_resource_type_and_resource_id"})
-> 0.0028s
-- add_index("roles", ["name"], {:name=>"index_roles_on_name"})
-> 0.0028s
-- create_table("users", {:force=>true})
-> 0.0899s
-- add_index("users", ["email"], {:name=>"index_users_on_email", :unique=>true})
-> 0.0045s
-- add_index("users", ["reset_password_token"], {:name=>"index_users_on_reset_password_token", :unique=>true})
-> 0.0061s
-- create_table("users_roles", {:id=>false, :force=>true})
-> 0.0663s
-- add_index("users_roles", ["user_id", "role_id"], {:name=>"index_users_roles_on_user_id_and_role_id"})
-> 0.0088s
-- initialize_schema_migrations_table()
-> 0.0136s
-- assume_migrated_upto_version(20121210211049, ["/my_app/db/migrate"])
-> 0.0358s
CREATING ROLES
SETTING UP DEFAULT USER LOGIN
New user created: First User
New user created: Second User
New user created: Third User
New user created: Fourth User
这可能是什么原因造成的?