I want to render a link only if the condition is met with the following link_to_if
:
<%= link_to_if policy(@user.add?), new_entry_path(), class: 'btn' do %>
<%= glyphicon("plus") %>
<% end %>
The block with the glypicon("plus")
helper method should also only be called if the condition of the link_to_if
is met. With the code above the block is always called, no matter whether the condition is true or false.
How do I create the link and its inner content only if the condition returns true?