My apologies if this is a dumb question, but I’ve searched around and
haven’t been able to come up with a solution.
Is there a way when specifying a has_one association to specify a
default value for an object if data is missing in the child table. For
instance:
class Student
has_one :university
end
if no university is associated to the student in the database, I would
like to automatically return an instance of NoUniverisity class instead
of it being set to nil. Similar to the NullObject refactoring described
in Fowler’s book.
Any ideas?
Thanks!
Jay