Rails 3 View: Difference between revisions

From Wiki
Jump to navigation Jump to search
Created page with 'Helpers are intended to generate complicated markup for use in the associated views.'
 
No edit summary
Line 1: Line 1:
Helpers are intended to generate complicated markup for use in the associated views.
Helpers are intended to generate complicated markup for use in the associated views.
== Layouts ==
* The default layout for the entire application is <code>app/views/layouts/application.html.erb</code>. 
* If controller-specific layouts are found, they are used instead.
* You can use the layout directive at the class level in any controller (that is, not inside an action) to set the layout for the entire controller:
<source lang="ruby">
layout 'my_layout'
</source>
* You can include a layout for a specific action with an explicit call to render inside the action:
<source lang="ruby">
render :layout => 'my_layout'
</source>
* Sometimes, you want to render an action without a layout. In that case, you can pass false in place of the layout name:
<source lang="ruby">
render :layout => false
</source>

Revision as of 22:05, 5 July 2011

Helpers are intended to generate complicated markup for use in the associated views.

Layouts

  • The default layout for the entire application is app/views/layouts/application.html.erb.
  • If controller-specific layouts are found, they are used instead.
  • You can use the layout directive at the class level in any controller (that is, not inside an action) to set the layout for the entire controller:
layout 'my_layout'
  • You can include a layout for a specific action with an explicit call to render inside the action:
render :layout => 'my_layout'
  • Sometimes, you want to render an action without a layout. In that case, you can pass false in place of the layout name:
render :layout => false