scinote-web/app/models/view_state.rb
2019-06-11 10:08:33 +02:00

20 lines
345 B
Ruby

# frozen_string_literal:true
class ViewState < ApplicationRecord
belongs_to :user
belongs_to :viewable, polymorphic: true
validates :viewable_id, uniqueness: {
scope: %i(viewable_type user_id),
message: :not_unique
}
validate :validate_state
private
def validate_state
viewable.validate_view_state(self)
end
end