开发者

How do I write a conditional to test which page I'm on in Rails?

What I would like to do is to not show the headder in my rails app if the user is on the home page. Right now, the header is rendered in this line in application.html.erb:

<%= render('layouts/header') %>

What I'd like to do is put a conditional so that this doesn't get rendered if I'm on the home page. I think it should be something like:

<%= render('layouts/header') if not @homepage %>

where I s开发者_Python百科et @homepage to true in the controller for the homepage. Does this approach make sense within the rails framework?


There are a few ways to do this, the easiest is probably:

<%= render('layouts/header') unless params[:controller] == 'homepage' %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜