forgeplus/app/models/watcher.rb

8 lines
251 B
Ruby
Raw Normal View History

2020-03-09 00:40:16 +08:00
class Watcher < ApplicationRecord
belongs_to :user
2020-06-03 18:23:53 +08:00
2020-03-09 00:40:16 +08:00
belongs_to :watchable, polymorphic: true, counter_cache: :watchers_count
2020-06-03 18:23:53 +08:00
scope :watching_users, ->(watchable_id){ where("watchable_type = ? and user_id = ?",'User',watchable_id)}
2020-03-09 00:40:16 +08:00
end