In my code, Author has_many Books, so I could do something like:
@author.books
If the author has no books, when @author.books is called, I’d like a default book object with that author’s info already filled out (i.e. author_id), something like:
class Author < ActiveRecord::Base
has_many :books
def books
the_books || default_book
end
end
That’s obviously not real code, but it demonstrates what I’m trying to do.
How about: