undefined method `relative_url_root'

Hi all,

I've installed the ym4rgm plugin so that I can integrate a google map to pinpoint locations of photos. I cant find where the error refers to. I got the API key from google for http://localhost and put it into config/gmaps_api_key (development and test).

The error is: undefined method `relative_url_root' for ActionController::Base:Class Extracted source (around line #2): 1: <% content_for :head do %> 2: <%= GMap.header %> 3: <% end %> 4:

My photos_controller show method is:

def show     @photo = Photo.find_by_user_id_and_id(params[:user_id],                                           params[:id],                                           :include => :user)     if @photo.show_geo && (@photo.geo_lat && @photo.geo_long)       @map = GMap.new("map_div_id")       @map.control_init(:map_type => false, :small_zoom => true)       @map.center_zoom_init([@photo.geo_lat, @photo.geo_long], 8)

      marker = GMarker.new([@photo.geo_lat, @photo.geo_long],                            :title => @photo.title,                            :info_window => @photo.body)       @map.overlay_init(marker)     end     respond_to do |format|       format.html # show.rhtml       format.xml { render :xml => @photo.to_xml }     end   end

The code for displaying the embedded map (show) is:

<% content_for :head do %>   <%= GMap.header %> <% end %>

<%= image_tag @photo.public_filename, :id => 'photo' %>

<% if @map %>   <div id="gmap">     <%= link_to_function 'Hide Map',           "Element.hide('gmap'); Element.show('showmaplink')" %>     <%= @map.to_html %>     <%= @map.div(:width => 650, :height => 200) %>     <br />   </div>   <%= link_to_function 'Show Map',         "Element.show('gmap'); Element.hide('showmaplink')",         :id => 'showmaplink',         :style => 'display:none' %> <% end %>

The source the the error is the ym4rgm plugin:

a << "<script src=\"#{ActionController::Base.relative_url_root}/ javascripts/ym4r-gm.js\" type=\"text/javascript\"></script>\n" unless options[:without_js]

However, it's strange that that error is happening, as ActionController::Base.relative_url_root has been around for awhile. What version of Rails are you running? You can also try changing that line in ym4r_gm/lib/gm_plugin/map.rb to something like:

a << javascript_include_tag 'ym4r-gm' unless options[:without_js}

To see if that resolves the issue.

pharrington wrote: > The source the the error is the ym4rgm plugin:

> However, it's strange that that error is happening, as > ActionController::Base.relative_url_root has been around for awhile. > What version of Rails are you running? You can also try changing that > line in ym4r_gm/lib/gm_plugin/map.rb to something like:

> On May 3, 11:39 am, Stephen Fagan <rails-mailing-l...@andreas-s.net>

Hi,

I'm using 2.0.2.

THat;s before relative_url_root was defined on ActionController::Base (used to live on AbstractRequest or something like that). If you're new to rails and don't have historical baggage you may find it easier to pick a newer version of rails.

Fred

Frederick Cheung wrote: