简体   繁体   English

纬度/经度在Ruby的EXIFR宝石中无法正常显示

[英]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.

相关问题 使用Geocoder Gem验证经度/纬度 - Validating Longitude/Latitude with Geocoder Gem 使用Geocoder gem验证经度/纬度 - Validating longitude / latitude with geocoder gem 红宝石地理编码器的宝石是否会消耗提供商规定的配额以获取经度/纬度和国家/地区代码? - Does ruby geocoder gem consume quota imposed by providers to get latitude/longitude and country code? 在Ruby On Rails中获取经度和纬度 - Get Latitude and Longitude in Ruby On Rails Ruby Geocoder不更新纬度/经度Rails 4 - Ruby Geocoder not updating latitude/longitude Rails 4 通过街道地址,通过Geocoder gem地理编码更新经度/纬度 - Update longitude / latitude with geocoder gem geocode by street address 使用geocoder gem查找经度和纬度附近的学校附近的学校 - Find Near banks , schools from latitude and longitude using geocoder gem 从rails-geocoder gem中的控制器获取纬度和经度值 - getting latitude and longitude values from controller in rails-geocoder gem 我们可以在使用gecoder宝石时检查经度和纬度的唯一性吗? - Can we check the uniqueness of latitude and longitude while using gecoder gem? 谷歌地图添加标记到地图,然后在Ruby on Rails中存储纬度和经度 - Google Maps Add a Marker to Map, then Store Latitude and Longitude in Ruby on Rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM