I have this code in a model in a Rails project.
validates :name, presence: true, on: :create
validates :email, presence: true, format: { with: URI::MailTo::EMAIL_REGEXP }, on: create
Let's put it in an Author model:
class Author
When retrieving a list of all of the authors without email addresses (because, well, we are cleaning up these things) with this line of code:
authors = Author.where(:email: nil)
... two new blank authors are created at the WHERE query. Both of their names and emails are blank. This is absurd!
Find the bug.