In the code below, I’m trying to make it so that, if a user has accepted an invite, they’ll be able to click on the “not attending” div to decline the invite.
That bit of logic works fine, but I’m trying to get it so the “not attending” div shows up regardless of whether the user has accepted the invite.
Right now, the div only appears if the user has accepted the invite.
Is there a way to make the link_to statement conditional, but preserve the div regardless? (That is, make it so the div is always present, but is only a link if the user’s accepted the invite?)
<% if invite.accepted %>
<%= link_to(:controller => "invites", :action => "not_attending") do %>
<div class="not_attending_div">
not attending
</div>
<% end %>
<% end %>
http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_if
Edit:
link_to_ifuseslink_to_unlesswhich useslink_to‘s code, it should work the same with the same optionsExample
check it here http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_unless
Edit:
Does this achieve what you need. Sorry, for not reading the question better.