search for: value_to_boolean

Displaying 4 results from an estimated 4 matches for "value_to_boolean".

2010 May 28
2
Suggestion for improving value_to_boolean column conversion
...boolean fields on a model will not generate any validation messages (it will silently be converted to false). I think it is like silently swallowing exception without knowing what to do about them. I will suggest to modify the existing implementation of ActiveRecord::ConnectionAdapters::Column::value_to_boolean to ActiveRecord::ConnectionAdapters::Column.class_eval %q{ def self.value_to_boolean(value) case value when *TRUE_VALUES.to_a: true when *FALSE_VALUES.to_a: false else nil end end } First of all it simplifies the implementation (getting rid of initial if. secondly it will...
2010 Sep 02
1
ActiveRecord::ConnectionAdapters::Column value_to_boolean(value) does not return a boolean value.
value_to_boolean(value), does not always return a boolean value, only when true. 150: def value_to_boolean(value) 151: if value.is_a?(String) && value.blank? 152: nil 153: else 154: TRUE_VALUES.include?(value) 155: end 156: end If valu...
2006 Feb 05
0
Enum patch for Rails
...when :boolean then Object + when :enum then Symbol end end @@ -61,6 +62,7 @@ when :date then self.class.string_to_date(value) when :binary then self.class.binary_to_string(value) when :boolean then self.class.value_to_boolean(value) + when :enum then value.intern else value end end @@ -77,6 +79,7 @@ when :date then "#{self.class.name}.string_to_date(#{var_name})" when :binary then "#{self.class.name}.binary_to_string(#{var_name})&quo...
2006 Jun 24
6
convert 0, "0", "true", etc. to boolean
Hi, is there a ruby / rails builtin function that converts - 0 / 1 - "0" / "1" - "yes" / "no" - "true" / "false" to a boolean? cheers peter