Class: ModelUpdates::UpdateChannel

Inherits:
ApplicationCable::Channel
  • Object
show all
Defined in:
app/channels/model_updates/update_channel.rb

Instance Method Summary collapse

Instance Method Details

#subscribedObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/channels/model_updates/update_channel.rb', line 2

def subscribed
  params[:ids].each do |model_class, ids|
    models = model_class.safe_constantize.accessible_by(current_ability).where(id: ids)

    ids_found = {}
    models.find_each do |model|
      next if ids_found.key?(model.id)
      ids_found[model.id] = true

      stream_for model
    end
  end
end