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 . -- Posted via http://www.ruby-forum.com/.
In the actions where you want a different layout try: def index ... render :layout => ''differentname'' end HTH, Jeff On 7/21/06, Ben V. <comprug@gmail.com> wrote:> > 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 . > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060721/a5bcb771/attachment.html
On 7/21/06, Ben V. <comprug@gmail.com> 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]
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]-- Posted via http://www.ruby-forum.com/.
On 7/21/06, Ben V. <comprug@gmail.com> 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
On 7/21/06, Ben V. <comprug@gmail.com> 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."
> 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? -- Posted via http://www.ruby-forum.com/.
On 7/21/06, Bill <devaulw@onebox.com> 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