From 6e33c8e92c04b0b9b4294e1b23144010a7c328f1 Mon Sep 17 00:00:00 2001 From: Junichi Sato <22004610+sato11@users.noreply.github.com> Date: Tue, 6 Feb 2024 19:10:41 +0900 Subject: [PATCH] Clarify an example that does not work as it is [ci-skip] This snippet was hard to decipher and I'd like to propose that it be clarified. `'_your_app_session'` as the default name of the cookie is a common placeholder throughout the guides which we can use for consistency. With these changes we are less likely to cause an immediate trouble, which is the NoMethodError as a result of `cookie.encrypted['_session']` being nil. --- guides/source/action_cable_overview.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/guides/source/action_cable_overview.md b/guides/source/action_cable_overview.md index ffd6873605c09..9cee8016f3c92 100644 --- a/guides/source/action_cable_overview.md +++ b/guides/source/action_cable_overview.md @@ -131,12 +131,10 @@ by this same current user, you're also ensuring that you can later retrieve all connections by a given user (and potentially disconnect them all if the user is deleted or unauthorized). -If your authentication approach includes using a session, you use cookie store for the -session, your session cookie is named `_session` and the user ID key is `user_id` you -can use this approach: +If your authentication approach includes using a session, you can use this approach: ```ruby -verified_user = User.find_by(id: cookies.encrypted['_session']['user_id']) +verified_user = User.find_by(id: cookies.encrypted['_your_app_session']['user_id']) ``` [`ActionCable::Connection::Base`]: https://api.rubyonrails.org/classes/ActionCable/Connection/Base.html