activeview - Create a "main layout" view in Rails? -


ok have small project 2 different scaffoldings i've made.in layouts directory therefor there 2 different layout.html.erb files.

my question how condense 1 main layout file 2 scaffolded views share.

basically purpose doing have have navigation bar , header , other such things in 1 place.

if name layout file application.html.erb, default layout file. if specify layout file same name of controller, override default layout.

from rails guides:

to find current layout, rails first looks file in app/views/layouts same base name controller. example, rendering actions photoscontroller class use app/views/layouts/photos.html.erb (or app/views/layouts/photos.builder). if there no such controller-specific layout, rails use app/views/layouts/application.html.erb or app/views/layouts/application.builder. if there no .erb layout, rails use .builder layout if 1 exists. rails provides several ways more precisely assign specific layouts individual controllers , actions.

source: http://guides.rails.info/layouts_and_rendering.html

edit:

i should add can specify layout default in application controller:

class applicationcontroller < actioncontroller::base   layout 'some_layout_name' end 

and override name matching rails automatically.

i hope helps!


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -