Well I'm making a lot of headway with reading an uploaded yml file that
contains values that are read and then inserted into the model.  The
formatted .yml file now looks like this:

theme:
  name: My Theme
  author: John Doe
  date: 2010-01-01
  stylesheets: true
  javascripts: false
  layouts: true
  swfs: true

I'm reading all of these yml values through a file upload which stores
it into a hash.

When saving the values to my database, all of the validators work
perfectly with the exception of the boolean reads.

validates_inclusion_of :stylesheets, :javascripts, :layouts, :swfs, :in
=> [true, false]

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.

theme:
  name: failure
  author: John Doe
  date: 2010-01-01
  stylesheets: true
  javascripts: booga
  layouts: true
  swfs: true

This will validate fine and store the javascripts as a boolean for
false.  Why does this validation not work with this?

Thanks.
-- 
Posted via http://www.ruby-forum.com/.
-- 
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