2017-10-22 22:38:48 +03:00
|
|
|
class Feedback < ActiveRecord::Base
|
|
|
|
belongs_to :feedback_receiving, polymorphic: true
|
|
|
|
|
|
|
|
validates :rating, presence: true, inclusion: {in: [2, 3, 4, 5 ,6]}
|
2017-10-23 00:29:21 +03:00
|
|
|
|
|
|
|
before_create :destroy_older_feedbacks_by_the_session
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def destroy_older_feedbacks_by_the_session
|
|
|
|
feedback_receiving.feedbacks.where(session_id: session_id).destroy_all
|
|
|
|
end
|
2017-10-22 22:38:48 +03:00
|
|
|
end
|