I’m trying to use a different/custom layout named “devise” for the sign_in action. I found this page in the devise wiki, and the second example even says you can do it per-action (in this case, sign_in action), but it shows no example of doing that. Someone on IRC told me I could try this:
class ApplicationController < ActionController::Base
protect_from_forgery
layout :layout_by_resource
def layout_by_resource
if devise_controller? && resource_name == :user && action_name == 'sign_in'
"devise"
else
"application"
end
end
end
But it does not seem to be working as it’s still loading the default application layout. I would appreciate any help.
I figured it out, but I’ll keep this question here in case other people are curious.
It was a stupid mistake. The fact is
sign_inis the path, not the action. Looking at the relevant source, I can see that the required action isnew, i.e., creating a new Devise Session. Changing my above code’s conditional to:Works beautifully.
Hope that helps someone out there.