Chronic を使用して時間を解析していますが、次のエラーが返されます。
ArgumentError in EventsController#create
comparison of Date with ActiveSupport::TimeWithZone failed
これは、Rails 2.1 以降、データベースと Ruby のタイムゾーンが異なるためです。
ステートメントを機能するように変換するにはどうすればよいですか?
def set_dates
unless self.natural_date.blank? || Chronic.parse(self.natural_date).blank?
# check if we are dealing with a date or a date + time
if time_provided?(self.natural_date)
self.date = nil
self.time = Chronic.parse(self.natural_date)
else
self.date = Chronic.parse(self.natural_date).to_date
self.time = nil
end
end