Search code examples
ruby-on-railsdeclarative-authorizationdevise

Is devise compatible with declarative_authorization?


Just asking whenever devise authentication mechanism for Rails does not conflict with 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.


Solution

  • 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)

    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.

    Hope that helps.

    Note: I am using Rails 3 beta, with the latest devise and declarative_authorization.