2010-12-18 52 views

回答

11

您可以添加一个before_filter

class ApplicationController < ActionController::Base 

    before_filter :authenticate 

    def authenticate 
    redirect_to :login unless User.find_by_provider_and_uid(auth["provider"], auth["uid"]) 
    end 
... 
end 

假设:1。 你已定义的链接(S)登录页面,如:<%= link_to "Sign in with Facebook", "/auth/facebook" %>

参见RailsCasts tagged with authentication