views:

620

answers:

3

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.

+1  A: 

I haven't used devise myself, but I have some experience with 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.

Tomas Markauskas
Not that simple. Infact declarative_authorization is not compatible with Authlogic.
jpartogi
Why not? I'm using declarative_authorization with authlogic now and didn't have any problems.
Tomas Markauskas
What Rails version are you using?
jpartogi
I'm still on 2.3.5. What are the problems when using both libraries with Rails 3?
Tomas Markauskas
+3  A: 

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.

jpartogi
+1  A: 

FYI - I wrote a very detailed post on using Devise for auth and CanCan for roles and permissions. I think the people reading this Q&A would appreciate it: http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/

Tony