I have created a polymorphic association around a model called status.
Some contacts will have a status associated with it. Many won't.
If I try to call a status when one is not there, I get an error. Right now, even if I haven't created a status for the model, it still runs whatever is in the if-end block.
Here's what I am trying, but it's not working:
<% if
[email protected]? %>
<p>Status: <%= @status.find(:last).status %></p>
<% end %>
In the controller, it is defined below:
@status = Contact.find(@contact).statuses
By the way, also open to make code more readable and DRY.