Question

I am trying to generate an incident_number in my Incident model as follows:

  def incident_number
    (self.created_at.strftime("%Y") + self.created_at.jd.to_s + self.id.to_s).to_i
  end

I am receiving an error that "jd" is an undefined method.

I can call Date.Today.jd to get the Julian Date of today, but how do I get the Julian Date of the "created_at" date?

Thanks in advance.

Was it helpful?

Solution

You have to convert the created_at to Date type of an object:

self.created_at.to_date.jd.to_s
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top