Class: ApplicationCable::Connection
- Inherits:
-
ActionCable::Connection::Base
- Object
- ActionCable::Connection::Base
- ApplicationCable::Connection
- Defined in:
- app/channels/application_cable/connection.rb
Overview
Action Cable connection for real-time WebSocket features.
Currently used for:
- Turbo Streams in CRM (retailer probe updates, sibling retailers tab)
Authentication:
- CRM: Requires authenticated employee account (via Warden/Devise)
- WWW: Not currently supported (connections rejected)
Future WWW Implementation (Option 2 - Lazy Connection):
When implementing real-time features for WWW (e.g., chat system):
- Don't auto-connect - wait until after globals.json establishes session
- Add visitor-based identification for anonymous users:
identified_by :current_account, :current_visitor - In primeval.js, create cable connection after globals.json:
if (data.csrf) { window.App.cable = createConsumer('/cable') } - Consider signed streams (Turbo 8+) for anonymous subscriptions
Action Cable base connection.
Instance Attribute Summary collapse
-
#warden ⇒ Warden::Proxy
readonly
The Warden proxy for the connecting request.
Instance Method Summary collapse
-
#connect ⇒ void
Authenticates the WebSocket connection.
Instance Attribute Details
#warden ⇒ Warden::Proxy (readonly)
Returns the Warden proxy for the connecting request.
32 33 34 |
# File 'app/channels/application_cable/connection.rb', line 32 def warden @warden end |
Instance Method Details
#connect ⇒ void
This method returns an undefined value.
Authenticates the WebSocket connection.
Rejects any connection that is not from the CRM subdomain with an
authenticated employee account, then identifies the connection by the
Warden user and stores the Warden proxy.
41 42 43 44 45 46 47 |
# File 'app/channels/application_cable/connection.rb', line 41 def connect # Only allow connections from CRM subdomain with authenticated users unless crm_subdomain? && authenticated_user? self.current_account = env['warden'].user @warden = env['warden'] end |