I don't need a User login in my website because i want to use a link parameter, in this way:
Link: www.website.com/link/2yM5KP6Vj6E3XdWS
/app/controllers/welcome_controller.rb
class WelcomeController < ApplicationController
def index
cookies[:link_param] = params[:link]
end
end
/app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = Link.find_by(token: cookies[:link_param])
end
end
end
But i don't want to use cookies for this, because it only expired when you close the browser and i want something like flash works but i can't use flash in ApplicationCable::Connection class.
A flash stores a value (normally text) until the next request
I'm doing this because i need to interact depending of link you enter and don't care how many user enter it. I don't want that ActionCable continue sending data because cookies[:link_param] is available.
Is there a way to do this or should i force to login system or use cookies.delete :link_param in all actions of all controllers i have.
Edit: Maybe this is an option from client side:
/app/assets/javascripts/channels/info.coffee
App.cable.subscriptions.create { channel: "InfoChannel", link_param: "#{link_param}" },
connected: ->
disconnected: ->
received: ->
Letting the customer say what link is.