# Relative\_url\_root and javascript\_include\_tag

**URL:** <https://www.ruby-forum.com/t/relative-url-root-and-javascript-include-tag/116998>\
**Category:** Rails\
**Created:** [October 11, 2007, 11:19pm UTC](https://www.ruby-forum.com/t/relative-url-root-and-javascript-include-tag/116998 "2007-10-11T23:19:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rickf](https://www.ruby-forum.com/u/rickf)\
**Post date:** [October 11, 2007, 11:19pm UTC](https://www.ruby-forum.com/t/relative-url-root-and-javascript-include-tag/116998/1 "2007-10-11T23:19:17Z")

</div>

Hi. In my environment.rb, I have:

ActionController::AbstractRequest.relative\_url\_root = “/foobar”

In my layout, I have:

\<%= javascript\_include\_tag :defaults %\>

Question 1:

I am getting an error:  
ActionController::RoutingError (no route found to match  
“/javascripts/prototype.js” with {:method=\>:get}):

When I remove the relative\_url\_root, everything works great. What  
gives?

Question 2:  
What is the javascript file I want to use ajax, but no visual effects?  
Can I load just one?

Thanks in advance.  
–rick

---

<div class="post-metadata">

**Author:** ![rickf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rickf](https://www.ruby-forum.com/u/rickf)\
**Post date:** [October 12, 2007, 5:21pm UTC](https://www.ruby-forum.com/t/relative-url-root-and-javascript-include-tag/116998/2 "2007-10-12T17:21:25Z")

</div>

Is anybody able to use javascript\_include\_tag with  
ActionController:AbstractRequest.relative\_url\_root?!

Rick Foreman wrote:

> Hi. In my environment.rb, I have:
> 
> ActionController::AbstractRequest.relative\_url\_root = “/foobar”
> 
> In my layout, I have:
> 
> \<%= javascript\_include\_tag :defaults %\>
> 
> I am getting an error:  
> ActionController::RoutingError (no route found to match  
> “/javascripts/prototype.js” with {:method=\>:get}):
> 
> When I remove the relative\_url\_root, everything works great. What  
> gives?

---

<div class="post-metadata">

**Author:** ![rickf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9e8a1a/32.png) [@rickf](https://www.ruby-forum.com/u/rickf)\
**Post date:** [February 14, 2008, 9:10am UTC](https://www.ruby-forum.com/t/relative-url-root-and-javascript-include-tag/116998/3 "2008-02-14T09:10:44Z")

</div>

I have the same problem, I’ve tried a zillion combinations of  
configuration, and I still can’t figure out any way to solve it.

When I use the asset tag helpers with :all, :cache=\>true and  
relative\_url\_root, asset loading behavior becomes completely erratic.  
Sometimes they load, sometimes they cache, and sometimes it’s a 404.

The first time I run this in production mode, I get an error like the  
one you posted, saying the files could not be found. Rails is looking in  
a directory structure that repeats the relative\_url\_root AFTER the asset  
directory ([some.host.com/foo/public/foo/javascripts/bar.js](http://some.host.com/foo/public/foo/javascripts/bar.js)).

A resulting concatenated all.js file is created which is empty.

I’d be ok with moving my javascripts to the extra directory, but in  
development mode (without caching), they are invisible and I get the  
same same error in reverse. Furthermore in development mode, the  
timestamp is not appended to the javascript files.

I can’t tell what’s breaking what… relative\_url\_root?  
javascript\_include\_tag? :cache=\>true?

Any help would be greatly appreciated…

thanks

Bill

Other config stuff:

OS X 10.4.10  
Apache 1.3  
Ruby 1.8.6  
Rails 2.0.2  
Mongrel 1.0.1
