diff --git a/actioncable/lib/action_cable/channel/streams.rb b/actioncable/lib/action_cable/channel/streams.rb index 94e78e7328..3fd0a2b237 100644 --- a/actioncable/lib/action_cable/channel/streams.rb +++ b/actioncable/lib/action_cable/channel/streams.rb @@ -124,13 +124,11 @@ module ActionCable end.clear end - # Calls stream_for if record is present, otherwise calls reject. - # This method is intended to be called when you're looking - # for a record based on a parameter, if its found it will start - # streaming. If the record is nil then it will reject the connection. - def stream_or_reject_for(record) - if record - stream_for record + # Calls stream_for with the given model if it's present to start streaming, + # otherwise rejects the subscription. + def stream_or_reject_for(model) + if model + stream_for model else reject end