I am using the ternary operator for single-line conditions, with erb printing tag <%= %>
<p>Status:
<%= notification.read? ? "Read" : link_to "Mark as Read", "/" %>
</p>
I need to give a mark as read link in false condition, in the above scenario getting the syntax template error, here notification is an object of the Notification model.
I want output as-
mark as read
mark as read would be link.
thanks!
Don't use a ternary:
Or use parentheses in the
link_tomethod call:Remember that anything inside
<%= ... %>is just Ruby and thatlink_tois just a Ruby method like any other.