class ContactMessage < ActiveRecord::Base belongs_to :customer belongs_to :admin belongs_to :contact, class_name: "Customer" paginates_per 5 acts_as_paranoid validates :content, :presence => true, length: {within: 1..1024} def conversation_id if customer customer.id elsif contact contact.id else nil end end def author_name if customer customer.fullname elsif admin admin.fullname + " (Administrateur)" else nil end end end