Hi I have included given code in my view
<% if employee.profile.present? %>
<%= employee.profile.name %>
<% end %>
Please guide me how to dry this code
Two ways I would suggest.
<%= employee.profile.try(:name) %>
<%= employee.profile.name if employee.profile %>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments