postgresql - How do I set a default value for an HStore field in a Ruby on Rails fixtures YAML file? -
i trying use ruby on rails 4.0 hstore extension postresql. make 1 of hstore fields required:
class thing < activerecord::base # ... validates :field_name, presence: true # ... end being new hstore, generated scaffold thing (rails g scaffold thing field_name:hstore). doing fixture file (test/fixtures/things.yml) did not include default value field_name:
one: # ... field_name: # ... which causes rake test fail since there no value provided required field.
my question is: how set value in fixtures yaml file field_name tests pass?
so far know:
this does not work:
one: # ... field_name: small: 2 medium: 5 large: 4 # ...this does not work:
one: # ... field_name: {"small"=>"2", "medium"=>"5", "large"=>"4"} # ...
thanks!
i using rails 4 , fixture file, options hstore field.
default: title: 'something' prefix: 'xxx' options: '"something"=>"2", ""=>"5"' i couldn't find out how use hash hard coded it.
Comments
Post a Comment