【问题标题】:Is devise compatible with declarative_authorization?设计与 declarative_authorization 兼容吗?
【发布时间】:2010-05-05 19:47:47
【问题描述】:

只要设计 Rails 的身份验证机制不与declarative_authorization 冲突时询问即可。

也许有人尝试过这个组合并且可以分享他们的知识,所以我和其他编码人员不会浪费时间尝试将这些组合起来。

【问题讨论】:

    标签: ruby-on-rails declarative-authorization devise


    【解决方案1】:

    是的。我目前在我的项目中同时使用这两种方法。

    一切都可以无缝运行。只需按照文档配置 devise 和 declarative_authorization 并将其设置在您的 application_controller.rb 中(也可在 declarative_authorization 文档中找到)

    before_filter :set_current_user
     protected
     def set_current_user
       Authorization.current_user = current_user
     end
    

    current_user 是 devise 提供的辅助方法。

    希望对您有所帮助。

    注意:我使用的是 Rails 3 beta,具有最新的设计和 declarative_authorization。

    【讨论】:

      【解决方案2】:

      我自己没有使用过设计,但我对 declarative_authorization 有一些经验。

      将它与设计一起使用应该不是问题,因为它根本不关心身份验证。 Declarative_authorization 只需要 User 模型有一个role_symbols 方法,否则与模型真正的作用无关。

      【讨论】:

      • 没那么简单。事实上 declarative_authorization 与 Authlogic 不兼容。
      • 为什么不呢?我现在将 declarative_authorization 与 authlogic 一起使用,没有任何问题。
      • 你使用的是什么 Rails 版本?
      • 我还在使用 2.3.5。在 Rails 3 中使用这两个库有什么问题?
      • 对于那些遇到这个问题的人,我已经在 Rails 3 中使用带有 declarative_authorization 的 Authlogic 有一段时间了,完全没有问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-21
      • 2015-08-09
      • 2018-08-27
      • 2011-12-31
      • 2020-03-19
      • 2018-05-18
      • 1970-01-01
      相关资源
      最近更新 更多