Closed darshan2101 closed 11 months ago
This seems to be the same issue as https://github.com/heartcombo/devise/issues/5571, please see my comment there regarding custom code added to make Devise work with Turbo before that version: https://github.com/heartcombo/devise/issues/5571#issuecomment-1469855659
If that's not the case, let us know how to reproduce and we can look further.
I am still facing that error and i am not doing anything special in particular to produce this error.After creating the new rails app and adding devise like this gem "devise", github: "heartcombo/devise" ,branch:"main" , I add initializer file with rails g devise:install and after that I added turbo support like here https://betterprogramming.pub/devise-auth-setup-in-rails-7-44240aaed4be , After all this I add devise setup with rails g devise User After that when i try to login or even sign up after starting rails server I get this specific error And One more thing I am not creating User model before setting up devise i am letting devise handle it
@darshan2101 that "turbo support" stuff is what I mentioned before regarding "custom code", you don't need any of that anymore, Devise works with turbo by default on version 4.9 forward.
Just install the latest (no need to pull from main, just the latest stable, 4.9.2 right now) and follow the basic install instructions to get it working.
This did the trick for me: https://github.com/heartcombo/devise/issues/5558#issuecomment-1434679268
Pre-check
Environment
Current behavior
Started POST "/users/sign_in" for ::1 at 2023-08-07 11:13:10 +0530 Processing by Users::SessionsController#create as TURBO_STREAM Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"admin@test.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"} User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? ORDER BY "users"."id" ASC LIMIT ? [["email", "admin@test.com"], ["LIMIT", 1]] ↳ app/controllers/users/sessions_controller.rb:13:in `create' Completed 201 Created in 262ms (Views: 0.1ms | ActiveRecord: 0.3ms | Allocations: 5264)
NoMethodError (undefined method `empty?' for #<User id: 2, email: "admin@test.com", created_at: "2023-08-07 05:38:35.135813000 +0000", updated_at: "2023-08-07 05:38:35.174091000 +0000", room_id: nil>):
activemodel (7.0.6) lib/active_model/attribute_methods.rb:450:in `method_missing'
Expected behavior ( below behaviour is from past when i was using devise version 4.8.1 )
Started POST "/users/sign_in" for ::1 at 2023-06-07 15:22:29 +0530 Processing by Devise::SessionsController#create as TURBO_STREAM Parameters: {"authenticity_token"=>"[FILTERED]", "user"=>{"email"=>"admin@test.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"} User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? ORDER BY "users"."id" ASC LIMIT ? [["email", "admin@example.com"], ["LIMIT", 1]] Redirected to http://localhost:3000/ Completed 302 Found in 264ms (ActiveRecord: 0.3ms | Allocations: 3233)