On Jan 12, 7:19 pm, Alpha Blue <[email protected]> wrote:
> If it contains true it does not fail and stores the value as true.
> If it contains false it does not fail and stores the value as false.
> If it contains nothing it fails and says that it must contain a boolean
> value.
>
> All good right?
>
> If it contains anything "booga, dodo, ugha, etc." it stores it as
> "false" and does not fail.  This is my problem.
>

It's likely you're having an issue with the AR typecasting code; the
relevant bit is from schema_definitions.rb:

        def value_to_boolean(value)
          if value.is_a?(String) && value.blank?
            nil
          else
            TRUE_VALUES.include?(value)
          end
        end

Essentially, anything that isn't blank and isn't "true-y" (see the
list in the source) gets mapped to false.

About the only way I can think of to avoid this is to override the
accessors for those variables and map everything that isn't true to
nil.

--Matt Jones
-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to