To start using the leaflet-rails gem, follow the steps below (assuming you use the default asset pipeline):
First, add the following code to your Gemfile
.
gem 'leaflet-rails'
Then, run bundle install
from within your project to download the necessary files. Following that, open your application-wide CSS file (app/assets/stylesheets/application.css
) and add the following line as a comment:
= require leaflet
If you require support for Internet Explorer, add the following line as well:
= require leaflet.ie
After that, open your application-wide Javascript file (typically app/assets/javascripts/application.js
) and add the following line before requiring files which depend on Leaflet:
= require leaflet
At this point, you may skip the first two steps of the Leaflet Quick Start guide and start at the third step (adding the map div
to a view).