I have admin controller and I want to set layout for ‘/admin’ path.
I try like:
scope '/admin' do
layout 'admin' # did't work
get '/' => 'admin#index', as: 'admin'
resources :posts, as: 'admin_posts'
end
I can set layout in AdminController like:
class AdminController < ApplicationController
layout 'admin'
end
but is a bad way because rationally use some layout for all controllers who call from ‘/admin’ path
How I can do it?
You cant set layout directly in your routes.rb
I think what you do is the right way
Now you will use AdminController to generate other controllers in admin scope
or if in a namespace
Thats what i do, if i did understand your question.