Spance
Spance

Reputation: 607

Render partial for only certain views

Hey I have a partial for a navigation bar in my rails project in my shared folder. I want it to load the nav bar for everything except any of my views associated with my score object. How can I write that condition out in the application.html.erb file?

<div id="wrapper">
        <%= render 'shared/navigation' if @some_condition %>
        <%= yield %>
</div>

Thanks!

Upvotes: 0

Views: 422

Answers (1)

Jon
Jon

Reputation: 2004

There is a current_page? helper in rails.

<% if current_page?(controller: 'score' action: 'show') %>
  <!-- render somthing -->
<% else %>
  <%= render 'shared/navigation' if @some_condition %>
  <%= yield %>
<% end %>

Link to information http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-current_page-3F

Upvotes: 3

Related Questions