I found a small bug in my last pull request which added the predicater methods: if you got an empty string like book.title = "" than book.title? will return TRUE - but should return FALSE!
The mistake was using !!value for all attributes, because in plain ruby
empty_string = ""
=> ""
!!empty_string
=> true
But Rails ActiveRecord does not simply use !!value - it differs between types and if the type is a string than it uses !value.blank? ... which is much better because of course if we check an object attribute with an emtpy string we want
I found a small bug in my last pull request which added the predicater methods: if you got an empty string like book.title = "" than book.title? will return TRUE - but should return FALSE!
The mistake was using !!value for all attributes, because in plain ruby
But Rails ActiveRecord does not simply use !!value - it differs between types and if the type is a string than it uses !value.blank? ... which is much better because of course if we check an object attribute with an emtpy string we want