[PLUGIN] url_for_with_prefix - allowing you to modify/remove

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.


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” # =>

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” # =>

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” # =>

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

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


Very nice.

Just FYI… I released a simliar plugin to this back in May.

See http://www.napcsweb.com/rdoc/reverse_proxy_fix/index.html for info

Mine is meant to be a site-wide approach for forcing users to come back
through a proxy. Yours looks great for making it really easy to
multiple applications with ease. Good work!!!

Posted at http://agilewebdevelopment.com/plugins/urlforwithprefix :slight_smile:

Benjamin C.
http://www.tesly.com/ – Collaborative test case management
http://www.agilewebdevelopment.com/ – Resources for the Rails community

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs