画像アップロードの緯度/経度を読み取るために exifr gem を使用しようとしています。
モデルでは:
attr_accessible :image, :post_process_photo, :width, :height, :model, :datetime, :latitude, :longitude
belongs_to :user
has_attached_file :image, styles: { medium: "300x300#", thumb: "50x50#", large:"500x500#" }
after_post_process :post_process_photo
def post_process_photo
imgfile = EXIFR::JPEG.new(image.queued_for_write[:original].path)
return unless imgfile
self.width = imgfile.width
self.height = imgfile.height
self.model = imgfile.model
self.datetime = imgfile.date_time
self.latitude = imgfile.gps.latitude
self.longitude = imgfile.gps.longitude
end
ビューでは...幅/高さは機能していますが、緯度/経度は機能していません:
<%= @pic.width %> #this works!
<%= @pic.height %> #this works!
<%= @pic.latitude %> #this doesn't!
<%= @pic.longitude %> #this doesn't!
... gem docsで指示されているとおりにマークアップされているため、これは奇妙です。
また、適切な移行を DB に追加しました。これは、スキーマに表示されるはずです。
ビューはundefined method
緯度をレンダリングします'`
どんな助けでも大歓迎です!