Join GoRails to continue learning
Subscribe to GoRails to get access to this episode and all other pro episodes, and access to our private Slack community of Ruby and Rails devs.
Episode 125 · June 28, 2016
Learn how to implement realtime notifications with ActionCable
# app/channels/application_cable/connection.rb module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verfied_user end protected def find_verfied_user # We can just access Warden directly to find out if the user is logged in or not # Using Warden directly will give us access to that as it's what Devise uses internally for authentication if current_user = env['warden'].user current_user else reject_unauthorized_connection end end end end
Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.