我在为我的用户模型编写规范时使用Devise 4.2.0来解决一些奇怪的问题:
password = 'password'
user = User.create!(email: 'test@test.dk', password: password)
user.password
# => 'password'
这怎么可能?
它在create语句中不可见:
SQL (0.7ms) INSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["email", "test@test.dk"], ["encrypted_password", "$2a$11$J.VxqiCi/4uJP/RPbz9EFe48qMiYKU5QJtn.7zlxNd5RJ/JLTfFd6"], ["created_at", 2016-10-11 09:48:50 UTC], ["updated_at", 2016-10-11 09:48:50 UTC]]
但是可以从控制台访问?
任何人都可以了解这里发生的事情?