-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails 7.0.1 with disabled Sessionstore ctionDispatch::Request::Session::DisabledSessionError (Your application has sessions disabled. To write to the session you must first configure a session store): #235
Comments
found some more infos to this problem |
It looks like a devise issue, right? I'll keep it open until it's fixed on their end. Thanks for the references. |
@arpu I ran into the exact same problem and I found for me it seemed to be related to the |
Hey @russellbrown can you point me to the code line? |
@arpu Sure, I just removed
... and the error disappeared. I had only included Hope that helps! |
@russellbrown I don't have
any thoughts here? Thanks |
@cchoi94 Oh ok, I don't know then, I just know it worked for me. What if you try removing rememberable? It uses cookies so that may also be causing the sessions issue. I know I had rememberable in my devise method but I also override devise's SessionsController so that may have bypassed it. |
@russellbrown thanks for getting back. Apologies I ended up moving ahead and although this is not a solution, I got everything to behave correctly by downgrading my rails to v6 rather v7. On another note, I also just changed my working devise to an m1 pro, so not sure if the shift in devices may be a contributor to the issue. |
@russellbrown @cchoi94 seems that you have moved on, but got my session storage to work on 7.0.2.4 by putting following code in (https://www.youtube.com/watch?v=PqizV5l1yFE @ 10:40 (references following ruby documentation: https://api.rubyonrails.org/v6.0.3.3/classes/ActionDispatch/Session/CookieStore.html#method-c-new))
|
Thanks, this worked for me using Rails 7.0.3 and Ruby 3.1.1 |
ActionDispatch::Request::Session::DisabledSessionError (Your application has sessions disabled. To write to the session you must first configure a session store): app/controllers/admin/sessions_controller.rb:16:in `create' same error after also session configuration in application.rb |
Workaround if you do not want to enable controller/concerns/rack_session_fix.rb
controller/registrations_controller.rb
|
Bro nmekutana nayo hii kitu pia, mbn sikupati kwa simu kaka |
This one worked for me by inserting as follows: module ExpertTowing
end |
This worked for me
|
Hi, I am facing this error test "should get index" do
sign_in users(:one)
get movies_url, as: :json
assert_response :success
end but even having both workarounds (the one in application.rb and the other having RackSessionFix.rb) is not working. Any ideas? Thanks. |
This also worked for me. I am using |
Setup:
in canse anyone else is struggling with this, you dont need to do any temp patching or enable cookie storre/session store.
The above could lead to potential bug when looking at the current_user as the session will only persist the last use that logged in and not the bearer token's user. (ie: link a service provider to a user)
Solution:
you can pretty much call sign_in :user, store: false anywhere you need and it will properly work, just dont forget the let devise know it should transmit the JWT in the header for yourr custom auth route for example:
Hopefully this saves people some time in the future 👍 |
This works for me. Thx ! |
I came late to the party, but I found @Dujota's solution being cleaner, and I found a way to centrally configure
This way you don't need to hack the session store in rack, it's enough to disable it altogether (if you don't use an
|
@Dujota / @janospapp 's solution also worked for me. It was enough to add...
... into config/initializers/devise.rb and the error went away and I was able to successfully sign_in / sign_out. |
I am also facing this issue. My development server does not throw any issues and works as expected when running the app using this addition to the config.session_store :cookie_store, key: '_interslice_session'
config.middleware.use ActionDispatch::Cookies
config.middleware.use config.session_store, config.session_options
config.api_only = true but when running
By the way, here's a link to the Rails docs regarding session. I've also run Even viewing the config while breakpointed in a test Anyone have any tips? Update: Eventually, I ended up narrowing the issue down to |
For some reason, neither Devise.setup do |config|
...
config.warden do |manager|
manager.scope_defaults :user, store: false
end
...
end nor module HasRackSession
extend ActiveSupport::Concern
class FakeRackSession < Hash
def enabled?
false
end
end
included do
before_action :set_fake_rack_session_for_devise
private
def set_fake_rack_session_for_devise
p "\n\n Hello \n\n"
request.env["rack.session"] ||= FakeRackSession.new
end
end
end work for me until I changed the Devise.setup do |config|
...
config.navigational_formats = []
...
end I don't even know what this does 🤔 |
It seems that I had a problem with production environment due to the replica database because when I commented the following lines the problem disappeared: # DB Replica
config.active_record_uses_replica_for_reading = true
config.active_record.database_selector = { delay: 2.seconds }
config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session What worked for me was to change the order of the middleware like mentioned here like this: config.api_only = true
config.session_store :cookie_store, key: "_interslice_session"
config.middleware.insert_before Rack::Head, ActionDispatch::Session::CookieStore, config.session_options
config.middleware.insert_before ActionDispatch::Session::CookieStore, ActionDispatch::Cookies I hope it helps. |
This worked for me |
Still a bug, but at least this solution has worked for me in an |
以下の変更を実施: - /config/routes.rb - `devise_for`メソッドに`module`オプションを追加指定 - /config/application.rb - セッション管理に必要なミドルウェアを追加 - /app/controllers/v1/users/registration_controller.rb - `create`アクションのコメントアウトを解除 - `configure_sign_up_params`メソッドに必要な箇所のコメントアウトを解除し、ユーザー登録に必要なキーを指定 - `configure_sign_up_params`メソッドを実行する`before_action`メソッドのコメントアウトを解除 - /spec/factories/users.rb - `password_confirmation`属性を追加 - /spec/requests/v1/users/registrations_spec.rb - `POST /v1/users` のエンドポイントのテストを作成し、ユーザー登録の正常動作を確認 参考: https://github.com/heartcombo/devise?tab=readme-ov-file#strong-parameters https://railsguides.jp/configuring.html#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%9F%E3%83%89%E3%83%AB%E3%82%A6%E3%82%A7%E3%82%A2%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B https://railsguides.jp/rails_on_rack.html#%E3%83%9F%E3%83%89%E3%83%AB%E3%82%A6%E3%82%A7%E3%82%A2%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html https://api.rubyonrails.org/classes/ActionDispatch/Session/CookieStore.html waiting-for-dev/devise-jwt#235 (comment)
Hey,
anything i miss on the update? any hint is welcome
updated from rails 6 to rails 7.01
Debugging information
The text was updated successfully, but these errors were encountered: