scinote-web/app/models/view_state.rb

21 lines
394 B
Ruby
Raw Normal View History

# 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
}
2019-06-13 20:28:46 +08:00
validate :validate_state_content
private
2019-06-13 20:28:46 +08:00
def validate_state_content
return unless state.present?
viewable.validate_view_state(self)
end
end