mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-05 07:03:51 +08:00
14 lines
328 B
Ruby
14 lines
328 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ViewableModel
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
has_many :view_states, as: :viewable, dependent: :destroy
|
|
end
|
|
|
|
def current_view_state(user)
|
|
state = view_states.where(user: user).take
|
|
state || view_states.create!(user: user, state: default_view_state)
|
|
end
|
|
end
|