Newer
Older
# == Schema Information
#
# Table name: complaints
#
# id :integer not null, primary key
# description :text
# user_id :integer
Marcela Ribeiro de Oliveira
committed
# complainable_id :integer
# complainable_type :string
# complaint_reason_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# *current_user* create complaint about *complaint_reason* for *complaintable*
Marcela Ribeiro de Oliveira
committed
belongs_to :complainable, polymorphic: true
Marcela Ribeiro de Oliveira
committed
validates_presence_of :user, :complainable, :description, :complaint_reason
validates :user_id, uniqueness: { scope: [:complainable_id, :complainable_type] }
def reason
complaint_reason.reason
end

Israel Barreto Sant'Anna
committed
def recipient
complainable
end