2013-02-14 83 views
0

我有一個本地web服務正在運行,需要將數據發佈到Rails以更新和添加記錄。我應該如何將此工作納入我的CanCan /設計認證/授權中?有沒有辦法允許在授權周圍僅進行本地主機訪問,或者與其他服務創建持久會話?允許本地webservice使用CanCan和Devise更新Rails數據

謝謝!

回答

1

,如果你想准許接入本地,

# application_controller.rb 
def current_ability 
    @current_ability ||= Ability.new(current_user, request.local?) 
end 

# ability.rb 
class Ability 
    include CanCan::Ability 
    def initialize(user, local) 
    can(:manage, :all) if local 
    ... 
    end 
end 
+0

感謝您的幫助! – robamaton 2013-02-14 17:06:21