-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from smellsblue/websocket-url-differentiation
Easy websocket url configuration
- Loading branch information
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module ActionCable | ||
module Helpers | ||
module ActionCableHelper | ||
# Returns an "action-cable-url" meta tag with the value of the url specified in your | ||
# configuration. Ensure this is above your javascript tag: | ||
# | ||
# <head> | ||
# <%= action_cable_meta_tag %> | ||
# <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> | ||
# </head> | ||
# | ||
# This is then used by ActionCable to determine the url of your websocket server. | ||
# Your CoffeeScript can then connect to the server without needing to specify the | ||
# url directly: | ||
# | ||
# #= require cable | ||
# @App = {} | ||
# App.cable = Cable.createConsumer() | ||
# | ||
# Make sure to specify the correct server location in each of your environments | ||
# config file: | ||
# | ||
# config.action_cable.url = "ws://example.com:28080" | ||
def action_cable_meta_tag | ||
tag "meta", name: "action-cable-url", content: Rails.application.config.action_cable.url | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters