SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: some help with template layout
-
Apr 16, 2008, 01:25 #1
- Join Date
- Jul 2006
- Posts
- 74
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
some help with template layout
Hello,
I got my main layout in views/layouts/application.rhtml Now what I
would like to do is wrap some code around everything in my
messages controller. (all actions)
How should I accomplish something like that? It is some navigation only related to that controller.
Best regards.
Asbjørn Morell.
-
Apr 16, 2008, 03:26 #2
- Join Date
- Feb 2006
- Location
- Worcs. UK
- Posts
- 404
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This line:
Code:layout 'application'
-
Apr 16, 2008, 04:46 #3
- Join Date
- Jul 2006
- Posts
- 74
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I still want to use my my application.rhtml layout as it holds header, body and footer. I guess I can call a partial from each message view :/
-
Apr 17, 2008, 03:28 #4
- Join Date
- Feb 2006
- Location
- Worcs. UK
- Posts
- 404
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
As long as the application.rhtml contains:
Code:<%= @content_for_layout %>
Code:<%= yield %>
That is, Rails automatically displays each view within the layout for the current controller. That layout will contain one of the two bits of code, and it is at that point within the layout, that the view code will be inserted.
Specifying layout 'application' forces the view for the controller to use the layout application.rhtml rather than /layout/controller_name.rhtml
Bookmarks