Reputation: 1498
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
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