2012-02-21 80 views
-1

我在我的Ruby問題上Rails代碼:錯誤而驗證

class SessionsController < ApplicationController 
     def new 
    @title = "Sign in" 
    end 
    def destroy 
    end 
    def create 
    user = User.authenticate(params[:session][:email], 
    params[:session][:password]) 
    if user.nil? 
    flash.now[:error] = "Invalid email/password combination." 
    @title = "Sign in" 
    render 'new' 
    else 
    sign_in user 
    redirect_to user 
    end 
    end 
    def destroy 
    sign_out 
    redirect_to root_path 
    end 
    end 

錯誤消息:

private method `has_password?' called for #<User:0xb729d558> 
app/models/user.rb:72:in `authenticate' 
app/controllers/sessions_controller.rb:8:in `create' 

我會如何解決這個問題?

回答

0

對於用戶認證,我建議你使用gems.Below是我更喜歡我的發展的寶石。朋友,我認爲這會有所幫助。

Devise

Authlogic

還可以訪問

Rails authentication