rake db:seed creates rows, but not the data
So when I run rake db:seed with some ruby to create 23 rows in a table, it creates the 23 rows but doesn't use the data I brin开发者_C百科g in. Code looks like this -
control_words = ControlWord.create([
{:text => 'herp', :status => 'positive'},
{:text => 'foo', :status => 'positive'}
])
It's probably something stupid but I've tried making an array and looping through each, but it gives me the same result. What am I doing wrong here?
Try this:
Make text
and status
fields as non-null. Then use ControlWord.create!
(with !
) and see if you get errors.
I have a feeling that you may be missing attr_accessible :text, :status
in your model, and those fields are probably nullable, thus no data and no errors.
精彩评论