class String

Monkey patching to avoid using ActiveRecord::Type::Boolean.new.cast Source: jeffgardner.org/2011/08/04/rails-string-to-boolean-method/

Public Instance Methods

to_bool() click to toggle source
# File lib/epb_view_models.rb, line 14
def to_bool
  return true   if self == true   || self =~ (/(true|t|yes|y|1)$/i)
  return false  if self == false  || blank? || self =~ (/(false|f|no|n|0)$/i)

  raise ArgumentError, "invalid value for Boolean: \"#{self}\""
end