orbit-basic/app/models/journal.rb

20 lines
306 B
Ruby

class Journal
include Mongoid::Document
include Mongoid::Timestamps
field :user_id
field :title
belongs_to :user
has_many :papers, :autosave => true, :dependent => :destroy
before_create :initialize_paper
def initialize_paper
for i in 0..25
self.papers.build
end
end
end