【发布时间】:2016-07-17 07:48:25
【问题描述】:
我正在使用 devise 在 rails 5 中制作应用程序。但是在迁移设计使用的用户模型后,结果如下:
User.new =>
User id: nil,
email: "",
created_at: nil,
updated_at: nil.
while 应该显示为:
User id: nil,
email: "",
encrypted_password: "",
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: nil,
updated_at: nil,
name: nil
这意味着没有创建字段。但是当我看到 mysql 数据库时,所有字段都在 users 表中创建。那为什么它没有显示在 rails 控制台内?
以下是 schema.rb:
ActiveRecord::Schema.define(version: 20160717050914) do
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.integer "failed_attempts", default: 0, null: false
t.string "unlock_token"
t.datetime "locked_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
end
end
【问题讨论】:
-
你
reload!你的 rails 控制台了吗?
标签: ruby-on-rails-5