Email attribute downcased when accessed via binding.pry

33 Views Asked by At

I have a method adjusts an auto-generated email for a user as part of a before_validation callback:

 def update_device_email
    binding.pry
    self.email = username.gsub(/\s/, '_') + FAKE_EMAIL_SUFFIX
    self.email_confirmation = email
  end

For some reason though when I hit the binding.pry call, it shows me a downcased version of the email, which then returns to normal after I call gsub:

enter image description here

Does anyone know why this may be happening?

1

There are 1 best solutions below

1
On

You should be checking what the username returns prior to the changes being made to self.email