Dealing with nil relation

I have a person table and a relation to a table for absents. When
listing absents I get the name by the relationship and the person_id.
But now I get an error because the person is deleted. How do I check if
a relation is missing?

you can check for nil of course...

<%= if @absent.person %>

But that is weak db/model design.

-Either don't allow deletion of persons and use an is_active flag
(most likely the best way to handle this)

- or make sure that if you delete a person all related records get
deleted too.
You can do this manually in the destroy action of the
or by using :dependent => destroy for all the associations.