Open workmaster2n opened 11 years ago
I'm having this same issue. Tried relocating img and theme folders to vendor, vendor/assets, vendor/assets/javascripts.
Make sure you are including the css in the asset pipeline either through application.css via require or through the config.assets.precompile property in either your production.rb or application.rb environment files. See this post for info on how to include all css/js:
The README only instructs you to do the following:
Add //= require openlayers-rails to your app/assets/javascripts/application.js manifest file.
which handles pulling the JS into the application, but not the CSS. I believe the images are pulled in by default. Although I'm not quite sure how the mechanism is working for the JS since the gem-name is specified instead of the actual javascript filename, "OpenLayers.js". Would love to know this if anyone finds out.
UPDATE: Figured out my above question.
http://guides.rubyonrails.org/asset_pipeline.html#asset-organization
2.2.2 Using Index Files
Sprockets uses files named index (with the relevant extensions) for a special purpose.
For example, if you have a jQuery library with many modules, which is stored in lib/assets/library_name, the file lib/assets/library_name/index.js serves as the manifest for all files in this library. This file could include a list of all the required files in order, or a simple require_tree directive.
The library as a whole can be accessed in the site's application manifest like so: //= require library_name
This simplifies maintenance and keeps things clean by allowing related code to be grouped before inclusion elsewhere.
UPDATE2: I was wrong, the index mechanism isn't being used. A simpler mechanism is used in this project.
This file simply includes the actual OpenLayer.js file.
@proteantech Doesn't the file https://github.com/tmikoss/openlayers-rails/blob/master/lib/openlayers-rails.rb add the css to the list of files to be precompiled?
@workmaster2n It appears you are correct. Are you resetting the "config.assets.precompile" anywhere? For example:
config.assets.precompile = [my.css]
May reset the assets to only precompile "my.css" and the work of the initializer in openlayers-rails.rb may be lost. Not sure on the order of how things get processed though, but I'm guessing you get the final say in your environment files and the gems are processed first. Comparing the format of the above code snippet to:
config.assets.precompile += [my.css]
Which would append to the current list.
I also suppose it's possible some other gem could be goofing up your precompile path. Try adding some logging in your environment file to output the precompile path and see what it looks like.
@workmaster2n is this still an issue?
@tmikoss We changed up the style.css
sheet in favor of themes, so we ended up having to modify the asset pipeline to load our custom css
files. Not sure if we would run into this problem without those custom style sheets. I vote to close this issue and I'll reopen it if my future endeavors find the same issue.
Hi folks,
i saw you are loading the style.css file like this:
this.theme = OpenLayers._getScriptLocation() + 'theme/default/style.css';
which is well working for development mode, but since you have to precompile your assets for production this is failing because style.css is named something like this now: style-369f8e7755ad2408de863713ca68bacb.css
You can get rid of this by importing or requiring the file explicit.
@import "openlayers/theme/default/style"; (in case you use sass)
//= require (in case you dont)
Of course this is a hack, the 404 still occurs, but the map is displayed correctly.
Is there any update? I use the latest version but it doesn't work in production mode and the solution from @RichardWieditz doesn't work too.
Please try using rails-assets-openlayers
gem from https://rails-assets.org/ - I'm not actively maintaining this gem any more.
The gem works perfectly in development, but when I deploy to my production server I get an error that
<domain>/assets/openlayers/theme/default/style.css 404 (Not Found)
. If I precompile the assets on my local machine, I notice that the folderassets/public/openlayers/theme/default
only contains animg
folder.Rails 3.2.13 Bundler 1.3.5