Class: ModelUpdates::CreateChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ApplicationCable::Channel
- ModelUpdates::CreateChannel
- Defined in:
- app/channels/model_updates/create_channel.rb
Instance Method Summary collapse
Instance Method Details
#subscribed ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'app/channels/model_updates/create_channel.rb', line 2 def subscribed model_class = params[:model].safe_constantize channel_name = "ModelUpdatesCreate#{params[:model]}" stream_from(channel_name, coder: ActiveSupport::JSON) do |data| model = model_class.accessible_by(current_ability).find(data.fetch("id")) next unless model transmit data end end |