Forum: Ruby on Rails layouts

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-02-23 14:39
(Received via mailing list)
I created a controller called reports, for which I didn't have any model
or tables.

I wanted to use a menu/layout structure similar to all my other
models/controllers and added a layout named reports which then gives me
the menu/layout structure but is also now part of all my reports.

That isn't gonna work so I renamed reports.rhtml to reports_forms.rhtml
(still inside my layouts directory) and then I created a model called
report.rb and inside it...

def forms
  render :action => "forms", :layout :=> "reports_forms"
def

but that doesn't work either.

How can I have a controller or view that selectively uses a layout?

Craig
Mikkel B. (Guest)
on 2006-02-23 14:48
(Received via mailing list)
>How can I have a controller or view that selectively uses a layout?
>
>Craig
>

http://api.rubyonrails.org/classes/ActionControlle...

Mikkel B.

www.strongside.dk    - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
Craig W. (Guest)
on 2006-02-23 15:06
(Received via mailing list)
On Thu, 2006-02-23 at 12:46 +0000, Mikkel B. wrote:
> >How can I have a controller or view that selectively uses a layout?
> >
> >Craig
> >
>
> http://api.rubyonrails.org/classes/ActionControlle...
----
I have been looking at that page and recited the changes I made after
looking at that page and can't figure it out.

Thanks

Craig
Doug B. (Guest)
on 2006-02-23 16:01
(Received via mailing list)
Use the "layout" method at the top of your controller.  layout
"layout-name".
For example: layout "admin"
Craig W. (Guest)
on 2006-02-23 16:13
(Received via mailing list)
That works the same as if I have a layout with the same name as the
controller - I am trying to selectively have a layout in some methods in
my reports_controller (the screen forms), but not on those that are
destined to be printed.

Craig
Craig W. (Guest)
on 2006-02-23 16:19
(Received via mailing list)
I got it...if I use

render :action => "forms", :layout => "reports_forms" as the very last
line in the method, it all works

Thanks

Craig
This topic is locked and can not be replied to.