I want to conditionally add the class "hidden" to a Rails link tag, depending on if "accepted == true".
If I weren't using a rails link_to
I could do <a href="#" class="foo bar <%= "hidden" if accepted == true %>" >
. How can I accomplish this inside a link_to
?
<%= link_to "Accept Friend Request",
"#",
class: "btn btn-success btn-sm btn-block requestSent ???hidden???",
disabled: true %>
You can do it outside the link_to
:
<% css_class = accepted ? "hidden" : "" %>
<%= link_to "Accept Friend Request",
"#",
class: "btn btn-success btn-sm btn-block requestSent #{css_class}",
disabled: true %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With