I am trying to use the Ruby on Rails 4.0 HStore extension for PostreSQL. I would like to make one of my HStore fields required:
class Thing < ActiveRecord::Base
# ...
validates :field_name, presence: true
# ...
end
Being new to HStore, I generated a scaffold for Thing (rails g scaffold Thing field_name:hstore
). Doing this my fixture file (test/fixtures/things.yml
) did not include a default value for field_name
:
one:
# ...
field_name:
# ...
Which causes rake test
to fail since there is no value provided for a required field.
My question is: How do I set a value in my fixtures YAML file for field_name
so that my tests will pass?
So far I know:
This does not work:
one: # ... field_name: small: 2 medium: 5 large: 4 # ...
This also does not work:
one: # ... field_name: {"small"=>"2", "medium"=>"5", "large"=>"4"} # ...
Thanks!