Reputation: 483
I want to render a partial but not show my button for one page. My partial looks like this;
.reward
%h4== #{number_to_currency(reward.price, precision:0)} Per Month
%h5= test.test
%h6 foo
%p= foo.description
%a.button.button-green{:href => foo(bar)} foo
And I call it like this
= render partial: 'foo', collection: bar.rewards
How can I render this partial without showing the button: This line:
%a.button.button-green{:href => foo(bar)} foo
Upvotes: 0
Views: 67
Reputation: 82
Pass another variable with your partial-rendering.
Partial:
.reward
%h4== #{number_to_currency(reward.price, precision:0)} Per Month
%h5= artist.number_of_supporters
%h6 Supporters
%p= reward.description
- unless nopledge
%a.button.button-green{:href => new_reward_pledge_path(reward)} Pledge
Rendering it:
= render partial: 'reward', collection: artist.rewards, nopledge: true
For those of you who don't know how this works, it's fairly simple: when you render a partial in Rails (ERb, HAML, anything) you can pass along variables for the partial to use. So using render 'reward', collection: artist.rewards
will give the "reward" partial access access to the artist.rewards
variable, but it'll be referenced in your partial as collection
. So you're able to do things like the code above does.
Upvotes: 1