From 53c82f6dc036fab537b67b011ae604af646a58a3 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sun, 12 Jul 2015 10:06:56 -0500 Subject: Add actionpack as a dependency --- lib/action_cable/connection/base.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/action_cable') diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb index ff7a98f777..5671dc1f88 100644 --- a/lib/action_cable/connection/base.rb +++ b/lib/action_cable/connection/base.rb @@ -1,3 +1,5 @@ +require 'action_dispatch/http/request' + module ActionCable module Connection # For every websocket the cable server is accepting, a Connection object will be instantiated. This instance becomes the parent @@ -117,7 +119,10 @@ module ActionCable protected # The request that initiated the websocket connection is available here. This gives access to the environment, cookies, etc. def request - @request ||= ActionDispatch::Request.new(Rails.application.env_config.merge(env)) + @request ||= begin + environment = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application + ActionDispatch::Request.new(environment || env) + end end # The cookies of the request that initiated the websocket connection. Useful for performing authorization checks. -- cgit v1.2.3