Insert time into time columns using Ruby on Rails

I have a problem which, in my opinion, is an Active Records error. I am parsing an XML file containing jobs. This xml file contains nodes that indicate the time of the wall in the format 00:00:00. I also have a model that will accept these tasks. However, when the time is greater than the actual 24-hour time, the active record inserts it as NULL. Examples below:

INSERT INTO `jobs` (`jobid`, `walltime`) VALUES('71413', 'NULL')

INSERT INTO `jobs` (`jobid`, `walltime`) VALUES('71413', '15:24:10')

Any ideas? Thank!

+5
source share
1 answer

SQL time datetime . , , ActiveRecord Ruby Time, .

, , :

  • (, " " )
  • () , .
class Thing < ActiveRecord::Base
  ...
  def duration
    return start - end
  end

  def duration=(length)
    start = Time.now
    end = start + length
  end
  ...
end
+5

All Articles