Rails doesn't generate created_at for fixture

后端 未结 2 1721
挽巷
挽巷 2020-12-21 04:19

I have a model Question with \"question_id\", \"elapsed_time\", \"allowed_time\" and \"status\" as its fields and a controller named Reporting that receive JSON containing q

2条回答
  •  星月不相逢
    2020-12-21 05:07

    As explained in https://stackoverflow.com/a/4350202/978525 you can add something like the following to your fixture objects:

    objectA:
      foo: something
      created_at: <%= 5.day.ago.to_s(:db) %>
      updated_at: <%= 5.day.ago.to_s(:db) %>
    

提交回复
热议问题