1
class SessionsController < ApplicationController
def new
@title = "Sign in"
end
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash[:error] = "Invalid email/password combination."
@title = "Sign in"
render 'new'
else
# Sign the user in and redirect to the user's show page.
end
end
def destroy
end
end
現在、プロジェクトで作業中で、未定義のNoMethodErorrがあります。徹底した調査を行っても何も見つかりませんでした。私がしたことは、作成アクションの中でparamsが認証に必要なパラメタを取ることです。次のUser.authenticatteメソッドを作成しました。しかし、これを私のlocalhostで実行すると、次のエラーが発生します。何が問題になる可能性がありますか?SessionsController#NoMethodError in SessionsController#create
NoMethodError in SessionsController#create
undefined method `authenticate' for #<Class:0x4589eb0>
ユーザーモデルはどのように見えますか? – Dogbert
はあなたのメソッド名 'authenticatte'です(あなたはその質問に言及しています)?その場合は、作成アクションで同じものを呼び出す必要があります。理想的には、それは 'authenticate'と呼ばれるべきです –
私は今投稿を返信してくれてありがとう – David