mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 05:23:43 +08:00
427d54b2b0
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. We no longer need to use Rails "require_dependency" anywhere and instead can just use standard Ruby patterns to require files. This is a far reaching change and we expect some followups here.
31 lines
559 B
Ruby
31 lines
559 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Developer < ActiveRecord::Base
|
|
belongs_to :user
|
|
|
|
after_save :rebuild_cache
|
|
after_destroy :rebuild_cache
|
|
|
|
@id_cache = DistributedCache.new('developer_ids')
|
|
|
|
def self.user_ids
|
|
@id_cache["ids"] || rebuild_cache
|
|
end
|
|
|
|
def self.rebuild_cache
|
|
@id_cache["ids"] = Set.new(Developer.pluck(:user_id))
|
|
end
|
|
|
|
def rebuild_cache
|
|
Developer.rebuild_cache
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: developers
|
|
#
|
|
# id :integer not null, primary key
|
|
# user_id :integer not null
|
|
#
|