0

For example, all pages need my Footer partial, but the home-page has a couple words that need to be different, and Page Y has one minor alteration too.

Evan
  • 7,396
  • 4
  • 32
  • 31

1 Answers1

1

You could check the controller and action name:

<% if controller.controller_name == 'Projects' && controller.action_name == 'index' %>
<p>Alternate content</p>
<% end %>

Alternatively, you could pass in a different local variables to the partial from the page(s) in question:

<%= render 'my_partial', :do_something_wierd => true %>

then, in 'my_partial':

<% if do_something_wierd %>
<p>Alternate content</p>
<% end %>
Isak
  • 1,591
  • 1
  • 17
  • 23