2011-04-13 79 views
0

我使用Devise在我的Rails 3应用程序中进行管理登录。我是唯一的管理员,所以我想限制位置的登录到我的状态,所以如果我处于我的状态,我只能登录到管理界面。我怎样才能做到这一点?Ruby on Rails and Devise:限制登录到一个位置

回答

2

您必须重写SessionsController。

class Users::SessionsController < Devise::SessionsController 
    before_filter :check_location, :only => [:new, :create] 

    private 
    def check_location 
    # There, you check the location of the ip address with for example GeoKit gem. 
    # https://github.com/jlecour/geokit-rails 
    end 
end