A layout for each action

How I make for using a layout for each action in a controller:

examplo

def show
layout ‘show’
bla bla bla bla
end

def list
layout ‘list’
bla bla bla bla
end

Marcelo J. :

layout ‘list’
bla bla bla bla
end

not tested :slight_smile:

class FooController < ApplicationController
layout :action_name

end

but if each action has a layout, why not putting each layout html code
in the action’s associated view ?

– Jean-François.


Ruby ( http://www.rubyfrance.org ) on Rails ( http://www.railsfrance.org
)

Marcelo J. wrote:

How I make for using a layout for each action in a controller:

examplo

def show
layout ‘show’
bla bla bla bla
end

def show
bla bla bla bla
render(:layout => ‘show’)
end

and so on…


Jakob S. - http://mentalized.net

It is old, but so what :stuck_out_tongue:

layout :layout

def layout
action_name
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs