Reputation: 391
I want to customize devise session & registration controller. I am even adding Active Admin to the app.
What is the correct process to override these controllers?
& I want to use both the controllers(customized as well as original). Is it possible?
When we are creating customized controllers, does same name cause any problem?
Thanks, Avi
Upvotes: 2
Views: 2430
Reputation: 1104
If you want to add a admin role to your devise, have a look at https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-role. If you want to customise your current devise You can customise the devise views by copying the views from the gem into your application and then modifying them. The below line would copy the views into your application
rails generate devise:views
If you want to modify controllers, Follow below steps
You would have to create your own customise controller say Admins::SessionsController
class Admins::SessionsController < Devise::SessionsController
end
Note that in the above example, the controller needs to be created in the app/controller/admins/ directory.
Now tell the router to use this controller
devise_for :admins, :controllers => { :sessions => "admins/sessions" }
And since we changed the controller, it won't use the "devise/sessions" views, so remember to copy "devise/sessions" to "admins/sessions".
There is a rail cast video for active admin at http://railscasts.com/episodes/284-active-admin
Upvotes: 2