Sha256: 465e853905c7928a44389731e1a3af112cf8621104146a8547d8efc06c943b49
Contents?: true
Size: 897 Bytes
Versions: 7
Compression:
Stored size: 897 Bytes
Contents
class Candidature < ActiveRecord::Base include StateMachines::Candidature belongs_to :vacancy belongs_to :offeror, class_name: 'User' belongs_to :resource, polymorphic: true has_many :comments, as: :commentable, dependent: :destroy scope :accepted, -> { where(state: 'accepted') } validates :vacancy_id, presence: true validates :offeror_id, presence: true validates :resource_id, presence: true, uniqueness: { scope: [:resource_type, :vacancy_id] } #validates :name, presence: true, uniqueness: { scope: :vacancy_id } attr_accessible :vacancy, :vacancy_id, :name, :text extend FriendlyId friendly_id :name, use: :slugged before_validation :set_offeror # association shortcuts def project vacancy.project end def product project.product end private def set_offeror self.offeror_id = vacancy.project.user_id end end
Version data entries
7 entries across 7 versions & 2 rubygems