Pat Maddox
2006-Jun-22 00:06 UTC
[Rails] [PLUGIN] url_for_with_prefix - allowing you to modify/remove prefixes easily
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 Maddox 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
Brian Hogan
2006-Jun-22 01:50 UTC
[Rails] [PLUGIN] url_for_with_prefix - allowing you to modify/remove prefixes easily
Pat: 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 on this 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 integrate multiple applications with ease. Good work!!! On 6/21/06, Pat Maddox <pergesu@gmail.com> wrote:> > 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 Maddox > > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060622/d44d49b5/attachment.html
Benjamin Curtis
2006-Jun-22 02:44 UTC
[Rails] [PLUGIN] url_for_with_prefix - allowing you to modify/remove prefixes easily
Posted at http://agilewebdevelopment.com/plugins/urlforwithprefix :) -- Benjamin Curtis http://www.bencurtis.com/ http://www.tesly.com/ -- Collaborative test case management http://www.agilewebdevelopment.com/ -- Resources for the Rails community On Jun 21, 2006, at 5:06 PM, Pat Maddox wrote:> 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 Maddox > > 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 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails