I've looked through many similar questions, and tried their suggestions, but I'm still getting a completely empty map (no controls). I'm pretty sure this is something simple...
Using Rails 3.1.2 and Ruby 1.9.2-p290
I have this in my footer:
<% = yield :scripts %>
Assets are enabled. My application.js has this line BEFORE the jquery lines:
//= require gmaps4rails/googlemaps.js
(I have also tried //= require ./gmaps4rails/googlemaps.js)
The assets/javascripts/gmaps4rails directory exists and it contains scripts.
My model code:
# 01/06/2012 - For Gmaps4Rails
acts_as_gmappable
...
def gmaps4rails_address
# 01/06/2012 - For Gmaps4Rails
"#{self.city}, #{self.country}"
end
My View:
<%= gmaps4rails(@json) %>
My controller:
@json = Party.all.to_gmaps4rails
@parties = Party.all
I am sure the JSON object has data, because (if I add it to the view) I can see it when the page renders: [{"lat":15.87,"lng":100.993},{"lat":37.0902,"lng":-95.7129}] Also, if I look in my local MySQL database those rows have latitude and longitude set, and gmaps=1
However, all I get is a large, completely empty map area (no controls).
My hunch is that the /gmaps4rails/... javascript is NOT getting pulled in. If I view source, I can see application.js, but it contains no mention of gmaps.
If I look in firebug under scripts... The only \localhost\assets script I see is application.js. Shouldn't I see googlemaps.js also?
The Gmaps javascript does appear in view source at the end (... Gmaps.map = new Gmaps4RailsGoogle(); ...)
I converted this rails app to a Rails 3 app about two months ago. Perhaps something that is normally automatically setup in a new rails 3 app generation is not enabled for me? Coffeescript?
What might I be doing wrong here? Any suggestions?
Thanks!
SOLVED! The problem was that my asset pipeline was all messed up due to the migration from an earlier rails version. Specifically, I had to do the following things to resolve this: First, add these lines in my gemfile:
# Gems used only for assets and not required
# in production environments by default.
# 01/14/2012 - DC needed to add this manually because this was UPGRADED!
group :assets do
gem 'sass-rails', '~> 3.1.5.rc.2'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
# 01/14/2012 - Needed this on linux to clear this bug: line 8: missing name after . operator
gem 'therubyracer', '>= 0.8.2'
Then a bundle update
I also deleted my \public\assets\application.js. I think this wasn't automatically getting recompiled because it was left over from my prior rails version.
After that, BooYah! It is working!