[英]Latitude/Longitude not woking in EXIFR gem for Ruby
Am trying to use the exifr gem to read lat/long for an image upload. 我正在尝试使用exifr gem读取经/纬度以上传图片。
In the model: 在模型中:
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
In the view... the width/height stuff is working, but lat/long isn't: 在视图中...宽度/高度的东西正在工作,但是纬度/经度却没有:
<%= @pic.width %> #this works!
<%= @pic.height %> #this works!
<%= @pic.latitude %> #this doesn't!
<%= @pic.longitude %> #this doesn't!
...which is odd, because it's marked up exactly as instructed in the gem docs . ...这很奇怪,因为它的标记完全按照gem docs的指示进行。
Have also added the appropriate migrations to the DB, which appear as should on the schema. 还向数据库添加了适当的迁移,该迁移在模式上应显示为正确。
The view renders undefined method
latitude'` 该视图呈现undefined method
纬度。
Any help much appreciated! 任何帮助,不胜感激!
我认为您想要imgfile.gps_latitude和imgfile.gps_longitude-强调而不是点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.