简体   繁体   中英

Namespace Layout rendering with Ruby on Rails

I have an application with a namespace 'admin'.

I created my views on a folder called admin->highligths. And want that, when my views are rendered, it gets the layout from 'admin/layouts/application'.

But, when I render my pages, it is getting from the base layout folder.

  Rendered admin/highlights/index.html.erb within layouts/application (0.7ms)

My routes are like this:

namespace :admin do root 'pages#show', id: 'dashboard'

resources :events
resources :invitees do
  collection do
    get 'import_invitees/:year' => 'invitees#import_invitees', as: :import_invitees
  end
end
resources :highlights
resources :pages
resources :speakers
resources :sponsors
resources :users
resources :years do
  resources :events do
    resources :photos
  end
end

end

All my other views (sponsours, invitees, etc...) are getting the template from 'admin/layouts/application' , but highlight (the new one I created)only render with the 'layouts/application'.

What Im missing here?

There are multiple possibilites. In the dark, I would assume that your other Controllers inherit from an AdminController (or similar), that defines the layout, but the "new one" does not.

For reference about how to make controllers use certain layouts by defaults: http://guides.rubyonrails.org/layouts_and_rendering.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM