2011-06-24 38 views
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。完成彻底的研究,仍然无法找到任何东西。我所做的是,在创建操作中,参数需要参数验证所需的参数。我创建了以下方法User.authenticatte。但是,当我在我的本地主机运行这个我得到以下错误。可能是什么问题?SessionsController中的NoMethodError#create

NoMethodError in SessionsController#create 

undefined method `authenticate' for #<Class:0x4589eb0> 
+0

你的用户模型是什么样的? – Dogbert

+0

是你的方法名'authenticatte'(你提到的问题)?如果是这样,那么你必须在创建操作中调用相同的方法。理想情况下,它应该被称为'authenticate' –

+0

我已经解决它现在感谢回复我的帖子 – David

回答

0

控制器正在为用户模型寻找Authenticate方法。此方法不存在。

相关问题