Sha256: 237a660a839405beccb305c2c436f9fa30cdad8602d4f8f951038cd8c3b55d7d

Contents?: true

Size: 1.49 KB

Versions: 31

Compression:

Stored size: 1.49 KB

Contents

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 Action Cable 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 environment
      # config files:
      #
      #   config.action_cable.mount_path = "/cable123"
      #   <%= action_cable_meta_tag %> would render:
      #   => <meta name="action-cable-url" content="/cable123" />
      #
      #   config.action_cable.url = "ws://actioncable.com"
      #   <%= action_cable_meta_tag %> would render:
      #   => <meta name="action-cable-url" content="ws://actioncable.com" />
      #
      def action_cable_meta_tag
        tag "meta", name: "action-cable-url", content: (
          ActionCable.server.config.url ||
          ActionCable.server.config.mount_path ||
          raise("No Action Cable URL configured -- please configure this at config.action_cable.url")
        )
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 4 rubygems

Version Path
actioncable-5.0.7.2 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.7.1 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.7 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.6 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.6.rc1 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.5 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.5.rc2 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.5.rc1 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.4 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.4.rc1 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.3 lib/action_cable/helpers/action_cable_helper.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/actioncable-5.0.2/lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.2 lib/action_cable/helpers/action_cable_helper.rb
actioncable-5.0.2.rc1 lib/action_cable/helpers/action_cable_helper.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/action_cable/helpers/action_cable_helper.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/action_cable/helpers/action_cable_helper.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/action_cable/helpers/action_cable_helper.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/action_cable/helpers/action_cable_helper.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/action_cable/helpers/action_cable_helper.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/action_cable/helpers/action_cable_helper.rb