I often find myself needing to add boolean virtual attributes to
ActiveRecord models which need to work with form helpers in the view.
Basically emulating the way that real, column boolean attributes work
foo = Foo.new
foo.bar = "1"
foo.bar #=> true
foo.bar? #=> true
After implementing this repeatedly, across multiple projects, I feel
like this could be a good candidate to encapsulate in a core extension
(along the lines of attr_accessor_with_default).
I created a lighthouse ticket, along with a patch, providing this
functionality in the form of 'boolean_attr_accessor':
Would be grateful to hear people's thoughts on this.
~ Mark Dodwell