Search code examples
ruby-on-railstemplatesconditional-statementspartial

trying to render a partial based on whether it's the home page "/"


I thought this bit of code might work, but...it didn't Any ideas?

<% if "/"? %>
  <%= render 'layouts/homeHeader' %>
<% else %>
  <%= render 'layouts/header' %>
<% end %>

Solution

  • According to this answer you can do this:

    <% if current_page?(root_url) %>
      <%= render 'layouts/homeHeader' %> 
    <% else %> 
      <%= render 'layouts/header' %> 
    <% end %>