2 layouts per .rb page


#1

Hi,

Is this possible

ive got layout “loggedout_layout”, :only => [:login, :logout]

but I also want to do somthing like
layout “loggedin_layout”, :except => [:login, :logout]

When the second one is introduced it seems to cancel out the first
request, any suggestions how to get around this?

Scott


#2

use this in your actions:

render [blah-blah], :layout => “bla”


#3

Hello Scott,

Is this possible

ive got layout “loggedout_layout”, :only => [:login, :logout]

but I also want to do somthing like
layout “loggedin_layout”, :except => [:login, :logout]

When the second one is introduced it seems to cancel out the first
request, any suggestions how to get around this?

Tell me if it works :

class MyBeautifulController < ApplicationController
layout :determine_layout

private
def determine_layout
if [:login, :logout].include?(controler.action_name)
“loggedout_layout”
else
“loggedin_layout”
end
end
end

-- Jean-François.

#4

Tell me if it works :

nice idea, but im gaining this error

NameError in AccountController#list

undefined local variable or method `controler’ for
#AccountController:0x38a7560

code

layout :determine_layout

private
def determine_layout
if [:login, :logout].include?(controler.action_name)
“loggedout_layout”
else
“loggedin_layout”
end
end


#5

Scott S. wrote:

Tell me if it works :

nice idea, but im gaining this error

if [:login, :logout].include?(controler.action_name)

2 'l’s in controller.action_name

Alan

p.s. can’t you specify :only and :except in the same layout line ?


#6

same problem again

undefined local variable or method `controller’ for
#AccountController:0x37da8e8

RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/controllers/account_controller.rb:14:in
`determine_layout’

In response to

can’t you specify :only and :except in the same layout line ?

totally new to ror, but I couldnt find a way to define 2 templates on
one line


#7

2006/4/20, Scott S. removed_email_address@domain.invalid:

Tell me if it works :

nice idea, but im gaining this error

NameError in AccountController#list

sorry for the typo :

controller.action_name

instead of

controler.action_name

-- Jean-François.

#8

I am still having problems with this, has anyone else got any
suggestions?


#9

2006/4/20, scott sherwood removed_email_address@domain.invalid:

I am still having problems with this, has anyone else got any
suggestions?

change this line

if [:login, :logout].include?(controler.action_name)

into :

if %w(login logout).include?(params[:action])

but it’s not very nice to me.

 -- Jean-François.