Reputation: 65
I'm trying to render a partial on home page. Code is a follows:
<%= render :partial => 'spree/shared/slider' %>
The thing is I want it to render/show the partial only if I'm on the home page .To summaries for a particular page/pages only.
Can anyone help me with this? Thank you.
Upvotes: 0
Views: 301
Reputation: 1873
You can use a conditional for deciding whether the partial should be rendered:
<%= render :partial => 'spree/shared/slider' if @slider %>
The condition could be an instance variable (e.g. @slider
) which can be set from the view (when not set, it remains nil by default):
<% @slider = true %>
Now the partial will only be rendered if @slider
has been explicitly set to true in the view or in the controller.
Upvotes: 1