clarion/app/models/proposition.rb

22 lines
693 B
Ruby
Raw Normal View History

class Proposition < ActiveRecord::Base
2019-04-28 21:10:54 +03:00
belongs_to :proposer, class_name: "User"
belongs_to :proposable, polymorphic: true, dependent: :destroy
enum status: [:undecided, :approved, :rejected, :backup]
2015-08-20 01:42:35 +03:00
delegate :proposable_title, :proposable_type, :proposable_description, to: :proposable
after_commit :send_creation_notification, on: [:create]
before_destroy :send_withdrawal_notification
2015-10-19 00:47:39 +03:00
def confirm!
update(confirmed_at: Time.now)
end
2015-08-20 01:42:35 +03:00
def send_creation_notification
PropositionMailer.new_proposition_notification(self).deliver_later
end
def send_withdrawal_notification
PropositionMailer.proposition_withdrawal_notification(self).deliver_later
end
end