I'm using no frameworks, only the rack gem to build a web application. I'm trying to set cookies to an successfully logged user:
use Rack::Session::Cookie
I'm getting the following error:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/rack-2.2.7/lib/rack/session/cookie.rb:155:in `<class:Cookie>': undefined method `DelegateClass' for Rack::Session::Cookie:Class (NoMethodError)
I already tried to specify rack version as
gem "rack", "~> 3.0"
but nothing changed.
How to fix it?
You probably recently updated from rack version 2 to 3. Or you are following a tutorial or documentation for rack version 2 but while running rack 3.
Quote from rack's UPGRADE-GUIDE.md:
Rack::Session
was moved to a separate gem.Previously,
Rack::Session
was part of therack
gem. Not every application needs it, and it increases the security surface area of therack
, so it was decided to extract it into its own gemrack-session
which can be updated independently.Applications that make use of
rack-session
will need to add that gem as a dependency:gem 'rack-session'