Rails: Multiple layouts with Devise -
how can have different layout depending on wether user logged in or not?
follow instructions at
https://github.com/plataformatec/devise/wiki/how-to%3a-create-custom-layouts
, make check if user logged in, devise means checkinguser_signed_in?
, devise helper.
specifically:
class applicationcontroller < actioncontroller::base layout :layout_by_resource protected def layout_by_resource if user_signed_in? "special_layout_name_for_logged_in" else "application" end end end
and put special_layout_for_logged_in.html.erb
view file in layouts directory.
Comments
Post a Comment