:
1. lambda ( )
2. before ( , )
-
. , HomeController, AdminController. index.
config/routes.rb
namespace :admin do
root to: "admin#index"
end
root to: "home#index"
/admin, '/'
, ; before_filter , admin.
3. .
, , , .
layout :admin_layout_filter
private
def admin_layout_filter
if admin_user?
"admin"
else
"application"
end
end
def admin_user?
current_user.present? && current_user.admin?
end
admin.html.erb
: -