This problem occurred for models which have child models.
Therefore I added before_create method in the model.
def before_create self.created_at = Time.now if self.created_at.blank? self.updated_at = Time.now if self.updated_at.blank? endThis method will fix the problem.