Matt.C.Wagner@wellsfargo.com
2006-Jan-16 20:42 UTC
[Rails] default_url_options for relative tag URLs
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. :) 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: <link href="/stylesheets/mystyle.css" ....> 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
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 Matt.C.Wagner@wellsfargo.com wrote:> 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. :) > > 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: > > <link href="/stylesheets/mystyle.css" ....> > > 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 >
Maybe Matching Threads
- simply_helpful's form_for not respecting default_url_options (only_path)
- Unable to set default_url_options[:host] for Action Mailer
- Absolutize URLs in a string
- Battle of Namings: stylesheet_link_tag vs link_to_javascript
- Problems with *_path() and *_url() helpers when using Publisher