我想進行自己的簡單身份驗證。 所以我做了用戶模型和用戶控制器。我有一個註冊表格 我的用戶控制器的一部分。控制器中'未知屬性'錯誤
def create
@user = User.new(user_params)
if @user.save
redirect_to root_path, notice: "You've successfully singed up."
else
render 'new'
end
end
private
def user_params
params.require(:user).permit(:username, :password, :password_confirmation)
end
和錯誤:
unknown attribute: password
在我的用戶表我有username
和password_digest
爲每個用戶。所以沒有像password
這樣的列。
我剛剛看過Rails Cast插曲,但它是關於Rails 3和作者使用attr_accessible
,但我在Rails 4中讀過,我們應該使用強參數。
我該如何處理它?
謝謝:)我在'has_secure_password'方法中有一個錯字。 – Jensky 2014-10-05 16:59:38