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:

  1. this does not work:

    one:   # ...   field_name:     small: 2     medium: 5     large: 4   # ... 
  2. 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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

mysql - Pass value between different pages (form) with PHP -