How does this syntax work?
before_validation { |user| user.email = email.downcase }
I would think it should be like this:
before_validation { |user| user.email = user.email.downcase }
Thank you for your help!
It works because
AS WELL AS
before_validation { |user| user.email = self.email.downcase }
This works, but keep the DRY principle of Ruby. That would be better:
before_validation { |user| user.email.downcase! }
! reflects changes back to the receiving object, and also saves a few keystrokes.
!
Source: https://habr.com/ru/post/1440237/More articles:What is the best way to implement this graphic design? (Android) - androidStatic text color - c ++Why doesn't git merge some changes? - gitmixing reagents and bit vectors - z3Changing the screen size in the browser causes problems in our application - jqueryCan I generate multiple SystemVerilog properties in a loop? - propertiesHow to change text color in menu item - javaError during In-app Purcahse (test products) with my andorid application from google game server - androidReaching target integer - javahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1440242/match-filenames-to-foldernames-then-move-files&usg=ALkJrhioNdfYMUszTGBn7CXJeevgI-BMCgAll Articles