devise icon indicating copy to clipboard operation
devise copied to clipboard

NoMethodError when finding user after Rails 7.2 upgrade.

Open knirirr opened this issue 6 months ago • 3 comments

  • Ruby 3.2.2
  • Rails 7.2.0
  • Devise 4.9.4

Following the upgrade, this code from app/models/user.rb:89:in 'find_for_database_authentication' triggers a NoMethodError:

 def self.find_for_database_authentication(warden_conditions)
    conditions = warden_conditions.dup
    login = conditions[:login]
    where(['lower(username) = :value OR lower(email) = :value', { value: login.downcase.strip }]).first if login  # NoMethodError thrown here
  end

The error:

NoMethodError (undefined method `name' for "john":String):

(i.e. this is the user's username).

Previously I was using Rails 7.1.3.3 and reverting to that fixes this issue (7.1.3.4 is fine as well). I can't upgrade to the latest master of Devise due to also using devise-jwt.

Strangely, this problem only affects the application when running in development mode.

knirirr avatar Aug 21 '24 13:08 knirirr