# Undefined method \`relative\_url\_root'

**URL:** <https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087>\
**Category:** Rails\
**Created:** [May 3, 2009, 5:32pm UTC](https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087 "2009-05-03T17:32:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![furrot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3da27b/32.png) [@furrot](https://www.ruby-forum.com/u/furrot)\
**Post date:** [May 3, 2009, 5:32pm UTC](https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087/1 "2009-05-03T17:32:18Z")

</div>

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](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 %\>

---

<div class="post-metadata">

**Author:** ![furrot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3da27b/32.png) [@furrot](https://www.ruby-forum.com/u/furrot)\
**Post date:** [May 3, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087/2 "2009-05-03T17:39:30Z")

</div>

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:in`show’

---

<div class="post-metadata">

**Author:** ![furrot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3da27b/32.png) [@furrot](https://www.ruby-forum.com/u/furrot)\
**Post date:** [May 4, 2009, 12:01am UTC](https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087/3 "2009-05-04T00:01:27Z")

</div>

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](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![furrot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3da27b/32.png) [@furrot](https://www.ruby-forum.com/u/furrot)\
**Post date:** [May 4, 2009, 10:03am UTC](https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087/4 "2009-05-04T10:03:04Z")

</div>

On May 4, 8:05 am, Stephen F. [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![furrot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3da27b/32.png) [@furrot](https://www.ruby-forum.com/u/furrot)\
**Post date:** [May 4, 2009, 9:05am UTC](https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087/5 "2009-05-04T09:05:41Z")

</div>

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](mailto: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 :@/

---

<div class="post-metadata">

**Author:** ![furrot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/3da27b/32.png) [@furrot](https://www.ruby-forum.com/u/furrot)\
**Post date:** [May 4, 2009, 12:27pm UTC](https://www.ruby-forum.com/t/undefined-method-relative-url-root/167087/6 "2009-05-04T12:27:41Z")

</div>

Frederick C. wrote:

> On May 4, 8:05ï¿½am, Stephen F. [removed\_email\_address@domain.invalid](mailto: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.
