datetime - Rails don't generate created_at for fixture -
i have model question "question_id", "elapsed_time", "allowed_time" , "status" fields , controller named reporting receive json containing questions , save it. ("question_id" not related of models)
so far there no problem. until try run tests. i've error when rails trying load question's fixture : activerecord::statementinvalid: sqlite3::constraintexception: questions.created_at may not null: insert "questions
"
here's fixture :
one: id: 1 question_id: mystring app: mystring guid: 1 status: 1 elapsed_time: 1 allowed_time: 1
and model :
class createquestions < activerecord::migration def change create_table :questions |t| t.string :app t.integer :guid t.string :question_id t.integer :elapsed_time t.integer :allowed_time t.datetime :happened_at t.integer :status t.timestamps end end end
any idea ?
my model's name in plural form. change singular , rails generate timestamp.
see how rails generate timestamp : https://github.com/rails/rails/blob/master/activerecord/lib/active_record/fixtures.rb#l560
Comments
Post a Comment