You could use presence
:
= link_to @element.title, (@element.link.presence || @element)
Or, if @element
might not have link
at all, you could use try
:
= link_to @element.title, (@element.try(:link) || @element)
You could use presence
:
= link_to @element.title, (@element.link.presence || @element)
Or, if @element
might not have link
at all, you could use try
:
= link_to @element.title, (@element.try(:link) || @element)