I need to restrict access to a route that communicates with a gem directly, and I cannot use a method of my ApplicationController.
Since I don't use an authentication gem like Devise, I don't have access to authenticate helpers in the routes file.
How do I access my signed cookies?
Implement a constraint as indicated in the Ruby on Rails guide, and use this to access your cookies:
cookies = ActionDispatch::Cookies::CookieJar.build(request, request.cookies)
You can now access your signed or encrypted cookies as usual:
cookies.signed[:user_id]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With