diff options
author | Mike Virata-Stone <mjstone@on-site.com> | 2015-09-03 17:17:48 -0700 |
---|---|---|
committer | Mike Virata-Stone <mjstone@on-site.com> | 2015-12-11 14:57:01 -0800 |
commit | 62250e38a1269030e036cf23a6ea6714fb00ffac (patch) | |
tree | e69f3dd5181d13ea195c6930536243ca1699e64a /lib/assets | |
parent | c362beab2edd3dcae248dfaaaf3e0dee12baafa8 (diff) | |
download | rails-62250e38a1269030e036cf23a6ea6714fb00ffac.tar.gz rails-62250e38a1269030e036cf23a6ea6714fb00ffac.tar.bz2 rails-62250e38a1269030e036cf23a6ea6714fb00ffac.zip |
Easy websocket url configuration
Thanks to feedback from @ascrazy, @jeremy, and @javan
Diffstat (limited to 'lib/assets')
-rw-r--r-- | lib/assets/javascripts/cable.coffee.erb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/assets/javascripts/cable.coffee.erb b/lib/assets/javascripts/cable.coffee.erb index 8498233c11..25a9fc79c2 100644 --- a/lib/assets/javascripts/cable.coffee.erb +++ b/lib/assets/javascripts/cable.coffee.erb @@ -4,5 +4,9 @@ @Cable = INTERNAL: <%= ActionCable::INTERNAL.to_json %> - createConsumer: (url) -> + createConsumer: (url = @getConfig("url")) -> new Cable.Consumer url + + getConfig: (name) -> + element = document.head.querySelector("meta[name='action-cable-#{name}']") + element?.getAttribute("content") |