Layouts

I am trying to set the layout for certain actions within a controller,
but not others, but doing
class JoinController < ApplicationController
layout ‘form’
def index
end
def add
end
end
sets layouts for all actions, and doing
class JoinController < ApplicationController
def index
layout ‘form’
end
def add
end
end
returns an error. Is there any way I can set the layout ‘form’ for the
index action, but not the add action? Thanks, I can’t find any other way
to call layouts .

In the actions where you want a different layout try:

def index

render :layout => ‘differentname’
end

HTH,
Jeff

On 7/21/06, Ben V. [email protected] wrote:

Is there any way I can set the layout ‘form’ for the
index action, but not the add action? Thanks, I can’t find any other way
to call layouts .

layout “form”, :except => [:add]

– OR –

layout “form”, :only => [:index]

On 7/21/06, Ben V. [email protected] wrote:

Actually I tried an “except”, but I guess I forgot a comma and a [.
Oops. I’m kinda new to rails, and the syntax is so different from my
native cf. Thanks,

Probably the comma. The array isn’t required, but I did it that way
to show you that you could put more than one symbol in there if you
wanted to.

– James

Actually I tried an “except”, but I guess I forgot a comma and a [.
Oops. I’m kinda new to rails, and the syntax is so different from my
native cf. Thanks,
Ben.

layout “form”, :except => [:add]

– OR –

layout “form”, :only => [:index]

On 7/21/06, Ben V. [email protected] wrote:

Actually I tried an “except”, but I guess I forgot a comma and a [.
Oops. I’m kinda new to rails, and the syntax is so different from my
native cf. Thanks,
Ben.

FYI

http://api.rubyonrails.org/

Click on “layout” under “Methods.”

On 7/21/06, Bill [email protected]domain.invalid wrote:

FYI

http://api.rubyonrails.org/

Click on “layout” under “Methods.”

I wonder if the API is helpful to Rails newbies. I tend to think not –
it wasn’t for me and I’ve read about others complaints. Are there
people who find the API a good place to learn about Rails?

To learn Rails? No.

To answer a question about the syntax of a specific method, such as
“layout”? Yeah.

– James

FYI

http://api.rubyonrails.org/

Click on “layout” under “Methods.”

I wonder if the API is helpful to Rails newbies. I tend to think not –
it wasn’t for me and I’ve read about others complaints. Are there
people who find the API a good place to learn about Rails?

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