开发者

Completely different home page

I have an application where my homepage is significantly different from other pag开发者_如何学JAVAes. SO can you suggest how I should use my layout?


You can change the layout for all actions in a controller with the following code:

class ThingsController < ApplicationController
  layout "my_layout"
  ...
end

You can change the layout for a specific action using the following code:

def ThingsController < ApplicationController
  def action
    ...
    # to render "app/views/things/action"
    render :layout => "my_layout"
    # or to render a specific view
    render "pages/something", :layout => "my_layout"
  end
end


If I got it right you are asking about how to manage multiple layouts for your project. What you could do is simply adding your layouts inside the layout directory and by referencing the one you want to use by adding this line to the controller:

layout "name_of_your_layout"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜