Note that there are some explanatory texts on larger screens.

plurals
  1. POPrecomopiling files doesnt work fine
    text
    copied!<p>I'm developing project with leaflet.js thing. I have javascript file that has to update coordinates of the company. So while I'm in development ENV, and rails use map_update.coffee.erb, everything is working smoothly. As soon as I'm trying to make rake assets:precompile and to start my local server in production ENV, map becomes broken. It's working, but absolutely different from development ENV.</p> <p>My js file is precompiled(I can see it in public/assets/map), because I explicitly precompile it in production.rb. But it doesn't work good. </p> <p>Any ideas would be great! And if you need some of my files, just ask me, I'll provide needed code, that I've wrote. Thanks!</p> <p>edit production.rb:</p> <pre><code>Application.configure do config.cache_classes = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.serve_static_assets = false config.assets.compress = true config.assets.compile = false config.assets.digest = true require 'syslog/logger' config.logger = Syslog::Logger.new 'abw' config.logger.level = 2 config.assets.precompile += %w( application-ie.css application-ie.js ) config.assets.precompile += %w( abwp.css.scss abwp.css xgemius.js ) config.assets.precompile += %w( map/map.js map/map_update.js ) config.i18n.fallbacks = true config.active_support.deprecation = :notify end </code></pre> <p>map_update.coffee.erb that is working in dev env and doesn't in production after precompilation:</p> <pre><code>#= require map/map.coffee.erb jQuery $ -&gt; coord = $('#coordinates-val').val().replace('[',"").replace(']',"").split(",").map(Number) loc = [coord[1], coord[0]] map.setCompanyLocation loc map.layers.companyLocationMarker.on 'dragend', (e) -&gt; $('#coordinates-val').val(e.target._latlng.lng + ", " + e.target._latlng.lat) $("#location-detector-update").on 'click', (e) -&gt; e.preventDefault() address = $("#location-address").val() errorElement = $("#location-error") if address.length &gt; 0 $.ajax url: 'http://geocode-maps.yandex.ru/1.x/' type: 'get' data: geocode: address format: 'json' results: 1 ,success: (data) =&gt; if typeof(data) == 'string' data = JSON.parse(data) if data.response.GeoObjectCollection.featureMember.length &gt; 0 _location = data.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos.split(" ") _location[0] = 0 if _location[0] == null _location[1] = 0 if _location[1] == null location = new L.LatLng(_location[1], _location[0]) map.setCompanyLocation location $('#coordinates-val').val(_location[0] + ", " + _location[1]) map.layers.companyLocationMarker.on 'dragend', (e) -&gt; $('#coordinates-val').val(e.target._latlng.lng + ", " + e.target._latlng.lat) errorElement.html "" else errorElement.html "Не найдено" </code></pre> <p>"Doesn't work" means, when I'm on the page of updating coordinates while running dev env, everything is work as I expect: if company has coordinates, it show them and give the apportunity to enter adress and posts another coorinates to the db. If company doesn't have coordinates, map is initializing in customized default place. In production env I see only marker and no map picture. Still can enter the adress find coordinates and post it to db, but I don't see the map itself and because of that can't move the marker to the right place. Ah, forgot. Cath the view: </p> <pre><code>#map .map-filter #location-error .input-append.adress-input = text_field_tag 'location-address', nil, class: 'input', placeholder: 'Enter your adress' = link_to nil, class: 'btn', id: 'location-detector-update' do i.icon-search = javascript_include_tag 'map/map_update' = render 'form_coordinates' </code></pre> <p>Hope that's enough for start.</p> <p>And one more thing. I have another view just to see the map of the company and I can do that. So the map is initializing properly. As I sad, problems in precompilation of my map_update.coffee.erb</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload