导轨错误在不存在的行上

时间:2016-03-22 12:35:57

标签: ruby-on-rails nginx

我有一个名为weekly_report_message.rb的文件,有26行代码

module MessageTypes
  class WeeklyReportMessage

    include Mongoid::Document
    include Mongoid::Timestamps

    field :last_week_date, type: DateTime
    field :this_week_date, type: DateTime
    field :runs, type: Integer
    field :runs_completed, type: Integer
    field :distance, type: Float
    field :distance_completed, type: Float
    has_one :message

    def basic_info
      {
        :last_week_date => !last_week_date.blank? ? last_week_date.strftime("%Y-%m-%d") : "",
        :this_week_date => !this_week_date.blank? ? this_week_date.strftime("%Y-%m-%d") : "",
        :runs => runs,
        :runs_completed => runs_completed,
        :distance => distance.round(1),
        :distance_completed => distance_completed.round(1)
      }
    end
  end
end

在某些情况下,此代码在本地计算机和生产服务器上正常工作,但有一种情况是调用basic_info方法并且此调用导致错误(仅在生产时),其中显示:

undefined method `strftime' for nil:NilClass
app/models/message_types/weekly_report_message.rb:30:in `basic_info'

但我在这个文件中没有30行,代码已部署,我用cat检查服务器上的代码并且与本地相同,无论我在此文件中做了什么更改,它仍然给我这个错误,我重新启动了nginx,但仍有此错误

0 个答案:

没有答案