davecom
davecom

Reputation: 1498

How does one use a rails admin account outside of rails admin to edit user data?

I would like to create a new controller that will allow the admin user to edit models attached to users outside of rails admin. Here is a sample from my routes.rb:

devise_for :admins

mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'

devise_for :dealers 
devise_for :users

get "..." => "..."
etc

What do I need to do in both my controller and in routes.rb to make this possible? I'm fairly new to Rails. Thanks! I have a limited amount of time so making a rails-admin plugin is not feasible.

Upvotes: 0

Views: 493

Answers (1)

Ismael
Ismael

Reputation: 16720

In your controller check if an admin is loged in using admin_signed_in?, and you can also access it by current_admin. So you just have to place conditions checking if it's and admin to enable or not those functionalities.

EDIT:

You can have something like this in your before_filter

before_filter :check_authentication

private

def check_authentication
  authenticate_user! unless admin_signed_in?
end

Upvotes: 1

Related Questions