开发者

Rails 3 render layout except for root_url

开发者 https://www.devze.com 2023-03-06 06:33 出处:网络
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 ar

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消