Module: C80Map::ApplicationHelper

Defined in:
app/helpers/c80_map/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_map(page_tag) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/c80_map/application_helper.rb', line 4

def render_map(page_tag)
  if page_tag == 'index'


    # map_settings = C80Map::Setting.first


    # т.к. в json попадают строки вида
    # /home/scout/git/bitbucket/vorsa/public/uploads/map/map.jpg
    # извлечём эту строку, затем во вью обработаем её image_path

    p = Rails.root.join("public", "locations.json")
    locs = File.read(p)
    locs_hash = JSON.parse(locs)
    locs_hash["img"] = image_path(locs_hash["img"])

    render :partial => 'c80_map/map_row_index',
           :locals => {
                locs_hash: locs_hash,
                mapwidth:locs_hash["mapwidth"],
                mapheight:locs_hash["mapheight"]
           }

  else
    render :partial => 'c80_map/map_row'
  end
end