From 62250e38a1269030e036cf23a6ea6714fb00ffac Mon Sep 17 00:00:00 2001 From: Mike Virata-Stone Date: Thu, 3 Sep 2015 17:17:48 -0700 Subject: Easy websocket url configuration Thanks to feedback from @ascrazy, @jeremy, and @javan --- lib/assets/javascripts/cable.coffee.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/assets') 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") -- cgit v1.2.3