Here’s the readme. I think it’s okay to post this kind of thing to
the mailing list. Anyway, hopefully someone else finds this useful.
UrlForWithPrefix
By Pat M.
Very simple plugin, adds the :prefix option to url_for.
Say in your environment.rb file you’ve got
ActionController::AbstractRequest.relative_url_root = “/super”
Any time you use link_to, it will prepend /super to the link. This
can be a pain if you want to link to other applications:
link_to “My Other App”, :controller => “other_app_controller” # =>
“http://mysite/super/other_app_controller”
You’d like to be able to set a different prefix, or take it out
altogether. With this plugin, you can do that:
link_to “My Other App”, :controller => “other_app_controller”,
:prefix => nil # => “http://mysite/other_app_controller”
link_to “My Other App”, :controller => “other_app_controller”,
:prefix => “/amazing” # =>
“http://mysite/amazing/other_app_controller”
Keep in mind when setting a new prefix, you must have a beginning /,
otherwise it will keep the original prefix AND use the new prefix:
link_to “My Other App”, :controller => “other_app_controller”,
:prefix => “amazing” # =>
“http://mysite/super/amazing/other_app_controller”
Wish I could say I had awesome unit tests, but I don’t. This has
worked in all of my apps so far, but I can’t guarantee that it won’t
break something, or that a future Rails update won’t break this
plugin.
I don’t really understand licenses, so do whatever you want with this,
I’d just appreciate a link back to www.flpr.org.
Plugin is available at
http://svn.flpr.org/public/plugins/url_for_with_prefix