Sha256: 787ac2f4f9c37a27c5863025c355d85a3337318f258a6440ac9e4db12bf09993
Contents?: true
Size: 718 Bytes
Versions: 18
Compression:
Stored size: 718 Bytes
Contents
module C80Map class Setting < ActiveRecord::Base mount_uploader :map_image, C80Map::MapImageUploader after_save :update_json def map_img MiniMagick::Image.open(map_image.path) end protected def update_json locations_path = Rails.root.join("public", "locations.json") locs = File.read(locations_path) puts "<update_json> #{ Rails.root.join("public", "locations.json") }" locs_hash = JSON.parse(locs) locs_hash["mapwidth"] = map_img["width"].to_s locs_hash["mapheight"] = map_img["height"].to_s locs_hash["img"] = map_image.url.to_s File.open(locations_path,'w') do |f| f.write(locs_hash.to_json) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems