alter the Author
model to be
class Author
include Mongoid::Document
embeds_many :books
field :name, type: String
attr_accessor :number_of_books
# this is plain old ruby class member not saved to the db but can be set and get
after_create :create_this_many_books
def create_this_many_books
self.number_of_books.each do |i|
books << Book.new
end
end
end