Sha256: 650e6638077020bbd403285a6957e71f2a72df068724bc48451afe2fe936eccc
Contents?: true
Size: 875 Bytes
Versions: 6
Compression:
Stored size: 875 Bytes
Contents
module C80MapFloors class MapJson < ActiveRecord::Base def self.update_json # открываем файл на чтение locations_path = Rails.root.join("public", "locations.json") locs = File.read(locations_path) locs_hash = JSON.parse(locs) # поместим в него детей - здания со всеми детьми и внуками buildings = [] C80MapFloors::MapBuilding.all.each do |map_building| buildings << map_building.my_as_json end locs_hash["buildings"] = buildings # запишем в файл File.open(locations_path, 'w') do |f| f.write(locs_hash.to_json) end end def self.fetch_json locations_path = Rails.root.join("public", "locations.json") locs = File.read(locations_path) JSON.parse(locs) end end end
Version data entries
6 entries across 6 versions & 1 rubygems