Вопрос

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.

Это было полезно?

Решение

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

self.created_at.to_date.jd.to_s
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top