api에서 내 객체를 저장하기 전에 유닉스 시간을 휴먼 시간으로 변환하고 싶습니다. 그러나 나는 내 방법 format date
에 액세스 할 수 없습니다, 그것은 나를 높이 :레일즈 : 모델에서 정의되지 않은 메소드
정의되지 않은 메서드`format_date 1,467,738,900,000에 대한 : Fixnum이라는
에게 내 모델 :
class Conference < ActiveRecord::Base
validates_presence_of :title, :date
validates :date, :uniqueness => true
def self.save_conference_from_api
data = self.new.data_from_api
self.new.parisrb_conferences(data).each do |line|
conference = self.new
conference.title = line['name']
conference.date = line['time'].format_date
conference.url = line['link']
if conference.valid?
conference.save
end
end
self.all
end
def format_date
DateTime.strptime(self.to_s,'%Q')
end
오류가 암시 하듯이'line [ 'time']'은 숫자이며,'Conference' 클래스의 인스턴스가 아닙니다. 그 이유는 게시 한 코드가 아닙니다. –