Default_url_options for relative tag URLs


#1

Hello,

I need help with using ‘default_url_options’. At least this is the
function that I think is involved in the solution I seek. :slight_smile:

I’m deploying my rails app beneath an Apache ProxyPass setup. I’ve got
it all working fine except that any rails tagging functions in my
templates create absolute URL references.

For example, this stylesheet function in my layout:

<%= stylesheet_link_tag ‘mystyle’ %>

Creates HTML like:

Referencing from the document root breaks my ProxyPass environment.

Of course I could just add /stylesheets/ and /javascripts/ and /images/
to my Apache ProxyPass config. But that doesn’t seem like the correct
solution.

Isn’t there some way within the rails framework to set all URLs to be
relative?

I’ve tried setting ‘:only_path = false’ in my controller/application.rb
def of defaults_url_options. But it doesn’t help.

Does anybody know how to solve this problem?

Thank you!

Matt


Matt C. Wagner
Information Security Analyst

Network Intrusion Detection
Security Operations Center
Corporate Information Security
Wells Fargo Bank


#2

There’s probably some spiffy rails way of doing this, but I’m still a
newbie so I don’t
know what it is. However, you could probably make this work just using
the html base tag:

http://www.w3schools.com/tags/tag_base.asp

Set the base tag in your layout.rhtml and all the urls on all pages that
use that layout
(the whole app?) will get that base url appended to them by the browser.

b