Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8334469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:21:49+00:00 2026-06-09T03:21:49+00:00

I have admin controller and I want to set layout for ‘/admin’ path. I

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:21:52+00:00Added an answer on June 9, 2026 at 3:21 am

    You cant set layout directly in your routes.rb

    I think what you do is the right way

    class AdminController < ApplicationController
      layout 'admin'
    end
    

    Now you will use AdminController to generate other controllers in admin scope

    class UsersController < AdminController
    end
    

    or if in a namespace

    class Admin::UsersController < AdminController
    end
    

    Thats what i do, if i did understand your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an admin module and I want it to serve dynamic controllers, i.e.
I have an admin controller located in controllers/admin/admin_controller.rb I also have a pages controller
I have a controller called Admin with a number of Actions. In the URL,
I have namespaced model Equipment::Feature and namespaced controller in my admin part Admin::Equipment::FeaturesController .
I don't have admin rights to my pc, but would like to use Mercurial
I'm working on an app in CodeIgniter, and I want to have admin pages
Hi I have a controller named places with some actions like view, new, create
So I am creating a website that I want to have an admin directory
I have a very simple admin controller in my Rails 2 app that displays
I want to create an admin controller - without having any menu items associated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.