Undefined method `relative_url_root'


#1

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

#2

Sorry, I should have added the trace:

vendor/plugins/ym4r_gm/lib/gm_plugin/map.rb:36:in header' app/views/user_photos/show.rhtml:2:in_run_erb_47app47views47user_photos47show46rhtml’
app/views/user_photos/show.rhtml:1:in
_run_erb_47app47views47user_photos47show46rhtml' app/controllers/user_photos_controller.rb:38:inshow’


#3

The source the the error is the ym4rgm plugin:

a << “<script src=”#{ActionController::Base.relative_url_root}/
javascripts/ym4r-gm.js" type=“text/javascript”>\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.

On May 3, 11:39 am, Stephen F. removed_email_address@domain.invalid


#4

On May 4, 8:05 am, Stephen F. removed_email_address@domain.invalid
wrote:

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


#5

pharrington wrote:

The source the the error is the ym4rgm plugin:

a << “<script src=”#{ActionController::Base.relative_url_root}/
javascripts/ym4r-gm.js" type=“text/javascript”>\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.

On May 3, 11:39�am, Stephen F. removed_email_address@domain.invalid

Hi,

I’m using 2.0.2. Im not 100% what you meant in your post. Do you mean
replace the whole line with the line a “<< javascript_include_tag
‘ym4r-gm’ unless options[:without_js}”? (This gives an ‘unexpected
tSTRING_BEG’ error). Apologies if this seems trivial, I am a novice to
rails :@/


#6

Frederick C. wrote:

On May 4, 8:05�am, Stephen F. removed_email_address@domain.invalid
wrote:

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

Thanks Fred. I’ll upgrade to current rails and see if how it goes

Stephen.