undefined method `relative_url_root''

Stephen Fagan
Sun, 03 May 2009 15:32:18 -0000

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 %>

    <%= link_to_function ''Hide Map'',
          "Element.hide(''gmap'');
Element.show(''showmaplink'')" %>
    <%= @map.to_html %>
    <%= @map.div(:width => 650, :height => 200) %>


  <%= link_to_function ''Show Map'',
        "Element.show(''gmap'');
Element.hide(''showmaplink'')",
        :id => ''showmaplink'',
        :style => ''display:none'' %>
<% end %>