简体   繁体   English

设计是否与declarative_authorization兼容?

[英]Is devise compatible with declarative_authorization?

Just asking whenever devise authentication mechanism for Rails does not conflict with declarative_authorization . 只要问每当Rails的设计认证机制与declarative_authorization不冲突时。

Maybe someone tried this combo and can share their knowledge, so I and other coders do not waste time trying to tie these ones up. 也许有人试过这个组合并且可以分享他们的知识,所以我和其他程序员不会浪费时间试图将这些组合起来。

Yes it is. 是的。 I am currently using both in my project now. 我现在正在我的项目中使用这两个。

Everything works seamlessly. 一切都无缝衔接。 Just configure devise and declarative_authorization as documented and set this in your application_controller.rb (which is also available in declarative_authorization docs) 只需按照文档配置devise和declarative_authorization,并在application_controller.rb设置它(也可以在declarative_authorization docs中找到)

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

current_user is a helper method that is provided by devise. current_user是由devise提供的辅助方法。

Hope that helps. 希望有所帮助。

Note : I am using Rails 3 beta, with the latest devise and declarative_authorization. 注意 :我正在使用Rails 3 beta,以及最新的设计和declarative_authorization。

I haven't used devise myself, but I have some experience with declarative_authorization. 我自己没有使用过设计,但我对declarative_authorization有一些经验。

It shouldn't be a problem to use it with devise as it doesn't care at all about authentication. 将它与设计一起使用应该不是问题,因为它根本不关心身份验证。 Declarative_authorization only needs the User model to have a role_symbols method and otherwise it doesn't matter what the model really does. Declarative_authorization只需要User模型有一个role_symbols方法,否则模型的确无关紧要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM