aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile.lock33
-rw-r--r--actioncable.gemspec1
-rw-r--r--lib/action_cable/connection/base.rb7
3 files changed, 39 insertions, 2 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index c1729aa227..46a6e8ec46 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -2,6 +2,7 @@ PATH
remote: .
specs:
actioncable (0.1.0)
+ actionpack (>= 4.2.0)
activesupport (>= 4.2.0)
celluloid (~> 0.16.0)
em-hiredis (~> 0.3.0)
@@ -12,17 +13,32 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- activesupport (4.2.3)
+ actionpack (4.2.1)
+ actionview (= 4.2.1)
+ activesupport (= 4.2.1)
+ rack (~> 1.6)
+ rack-test (~> 0.6.2)
+ rails-dom-testing (~> 1.0, >= 1.0.5)
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
+ actionview (4.2.1)
+ activesupport (= 4.2.1)
+ builder (~> 3.1)
+ erubis (~> 2.7.0)
+ rails-dom-testing (~> 1.0, >= 1.0.5)
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
+ activesupport (4.2.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
+ builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
em-hiredis (0.3.0)
eventmachine (~> 1.0)
hiredis (~> 0.5.0)
+ erubis (2.7.0)
eventmachine (1.0.7)
faye-websocket (0.9.2)
eventmachine (>= 0.12.0)
@@ -31,13 +47,28 @@ GEM
hitimes (1.2.2)
i18n (0.7.0)
json (1.8.3)
+ loofah (2.0.2)
+ nokogiri (>= 1.5.9)
metaclass (0.0.4)
+ mini_portile (0.6.2)
minitest (5.7.0)
mocha (1.1.0)
metaclass (~> 0.0.1)
+ nokogiri (1.6.6.2)
+ mini_portile (~> 0.6.0)
puma (2.10.2)
rack (>= 1.1, < 2.0)
rack (1.6.0)
+ rack-test (0.6.3)
+ rack (>= 1.0)
+ rails-deprecated_sanitizer (1.0.3)
+ activesupport (>= 4.2.0.alpha)
+ rails-dom-testing (1.0.6)
+ activesupport (>= 4.2.0.beta, < 5.0)
+ nokogiri (~> 1.6.0)
+ rails-deprecated_sanitizer (>= 1.0.1)
+ rails-html-sanitizer (1.0.2)
+ loofah (~> 2.0)
rake (10.4.2)
redis (3.2.1)
thread_safe (0.3.5)
diff --git a/actioncable.gemspec b/actioncable.gemspec
index 44e435a893..4103a51314 100644
--- a/actioncable.gemspec
+++ b/actioncable.gemspec
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.add_dependency 'activesupport', '>= 4.2.0'
+ s.add_dependency 'actionpack', '>= 4.2.0'
s.add_dependency 'faye-websocket', '~> 0.9.2'
s.add_dependency 'websocket-driver', '= 0.5.4'
s.add_dependency 'celluloid', '~> 0.16.0'
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.