How to customize the default login page in ActiveAdmin?

user456584 picture user456584 · May 14, 2014 · Viewed 8.6k times · Source

The Problem

I'm trying to customize the default login page in ActiveAdmin, but I'm having trouble getting the customizations to go through.

What I've tried

A commenter on this RailsCasts episode suggests copying this file to app/views/active_admin/devise/sessions/new.html.erb and customizing it from there. However, doing so does not seem to replace the default login form.

I also tried replacing devise_for :admin_users, ActiveAdmin::Devise.config with devise_for :admin_users as the commenter suggests, which seems to point the routes to the right place, but I get a bunch of server errors related to none of the ActiveAdmin variables being recognized in this context.

I've searched the docs, but I haven't been able to find documentation around customizing the login form in particular.

Question

What's the best way to go about customizing the login form in ActiveAdmin?

Answer

nioq picture nioq · Jul 16, 2014

With the default ActiveAdmin config where the Devise resource is admin_user, your new.html.erb should go in app/views/admin_users/sessions/new.html.erb instead.

An easy way to copy out all the Devise templates is to do rails g devise:views admin_users, though it turns out ActiveAdmin comes with its own versions of these views: https://github.com/gregbell/active_admin/tree/master/app/views/active_admin/devise

If you're additionally trying to change the layout that Devise's new.html.erb is rendered with, you can copy the layout file out from ActiveAdmin into app/views/layouts/active_admin_logged_out.html.erb

The current layout file used for the login page is here:

https://github.com/gregbell/active_admin/blob/master/app/views/layouts/active_admin_logged_out.html.erb