# == Schema Information # # Table name: complaints # # id :integer not null, primary key # description :text # user_id :integer # complaintable_id :integer # complaintable_type :string # complaint_reason_id :integer # created_at :datetime not null # updated_at :datetime not null # class Complaint < ActiveRecord::Base include Trackable belongs_to :complaint_reason belongs_to :user belongs_to :complaintable, polymorphic: true validates_presence_of :user, :complaintable, :description, :complaint_reason validates :user_id, uniqueness: { scope: [:complaintable_id, :complaintable_type] } def reason complaint_reason.reason end end