Devise admin role

1,240 views
Skip to first unread message

Escéptico

unread,
Apr 28, 2011, 3:21:53 PM4/28/11
to rails_admin
Hi,

I just started using rails_admin and I'm liking a lot.

I have set an admin role in devise as stated in
https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-role

Is there a way to use this to authenticate in rails_admin? I just want
users who have the admin role attribute set to true to be able to
access rails admin.

Thanks
Sebastián

Erik Östling

unread,
Apr 28, 2011, 3:27:52 PM4/28/11
to rails...@googlegroups.com
Hello Escéptico!

Permissions is easy to implement with CanCan. See how here: https://github.com/sferik/rails_admin/wiki/CanCan

E

> --
> You received this message because you are subscribed to the Google Groups "rails_admin" group.
> To post to this group, send email to rails...@googlegroups.com.
> To unsubscribe from this group, send email to rails_admin...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rails_admin?hl=en.
>

Escéptico

unread,
Apr 28, 2011, 4:50:23 PM4/28/11
to rails_admin
Hi Erik,

CanCan looks nice, but I'm already using Devise for other things in my
app, and I don't need all the different permissions, just that if the
user is admin he can access rails_admin.

I'm still gonna look into it while I try to find if it's possible with
devise.

Thanks

Erik Östling

unread,
Apr 28, 2011, 4:53:09 PM4/28/11
to rails...@googlegroups.com
CanCan is not a Devise replacement. You combine it with Devise to handle authorization. Check out the link I sent again. :)

E

Dmitry S. Denisov

unread,
Jun 6, 2011, 3:49:49 AM6/6/11
to rails_admin
hi,

in <your_app>/config/initializers/rails_admin.rb

put:

RailsAdmin.authorize_with do
redirect_to root_path unless current_user.try(:admin?)
end

assume you have 'admin' boolean in your 'user' model

with best regards,
Dmitry

On 29 апр, 02:21, Escéptico <lande...@gmail.com> wrote:
> Hi,
>
> I just started using rails_admin and I'm liking a lot.
>
> I have set an admin role in devise as stated inhttps://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-role
Reply all
Reply to author
Forward
0 new messages