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

Version Path
c80_map-0.1.0.24 app/models/c80_map/setting.rb
c80_map-0.1.0.23 app/models/c80_map/setting.rb
c80_map-0.1.0.22 app/models/c80_map/setting.rb
c80_map-0.1.0.21 app/models/c80_map/setting.rb
c80_map-0.1.0.20 app/models/c80_map/setting.rb
c80_map-0.1.0.19 app/models/c80_map/setting.rb
c80_map-0.1.0.18 app/models/c80_map/setting.rb
c80_map-0.1.0.17 app/models/c80_map/setting.rb
c80_map-0.1.0.16 app/models/c80_map/setting.rb
c80_map-0.1.0.15 app/models/c80_map/setting.rb
c80_map-0.1.0.14 app/models/c80_map/setting.rb
c80_map-0.1.0.13 app/models/c80_map/setting.rb
c80_map-0.1.0.12 app/models/c80_map/setting.rb
c80_map-0.1.0.11 app/models/c80_map/setting.rb
c80_map-0.1.0.10 app/models/c80_map/setting.rb
c80_map-0.1.0.2 app/models/c80_map/setting.rb
c80_map-0.1.0.1 app/models/c80_map/setting.rb
c80_map-0.1.0 app/models/c80_map/setting.rb