bigdir/app/models/softapplication.rb

25 lines
800 B
Ruby
Raw Normal View History

class Softapplication < ActiveRecord::Base
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id, :application_developers
2014-04-09 09:25:24 +08:00
acts_as_attachable
2014-04-18 16:35:48 +08:00
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :contesting_softapplications, :dependent => :destroy
belongs_to :user
belongs_to :contest
def add_jour(user, notes, reference_user_id = 0, options = {})
if options.count == 0
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
else
jfm = self.journals_for_messages.build(options)
jfm.save
jfm
end
end
def set_commit(commit)
self.update_attribute(:commit, commit)
end
end