Orbit/app/models/journal.rb

20 lines
305 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..5
self.papers.build
end
end
end