I want to have a different layout for the home page (root_url) than the other pages in my web app. I would like to be able to use开发者_开发问答 <%= render 'layouts/pages' %>
for pages that are not the home page. How do I go about doing this?
Majority
The best way to do this is to name the layout for the majority of your app layouts/application
- this way, Rails will automatically assume this layout for that majority without you needing to do anything else.
Home
For your home page, you can add this line to the bottom of your controller action:
render :layout => "home"
This will tell Rails not to use application
, but instead to point to your home/root page's layout, which in this case would be located at layouts/home
.
精彩评论