bugs

Find the bug, Rails edition

Blog

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.

Finding bugs

Blog

Okay, I know that software development is some parts writing codes, and a lot parts debugging code.

And I know that my finding a bug is much better than a customer finding a bug.

With this project, though, I'd really prefer to find ALL MY BUGS AT ONCE. I swear, I think I have it down, do one more test, and BOOM, hello bug number 472385.

Gah.

I know I'm being thorough, and I'm happy I'm finding these bugs, not someone else. These bugs are the result of my not yet having mastered the framework and tools and software, so it's unsurprising that I keep finding them. Thankfully I'm not pissed off at myself either. Or worse, somehow thinking something is wrong with me because I didn't have a magical instant understanding of all things on this project.

I will say, after this task, I will _KNOW_ this framework inside and out, whether I want to or not.