WARNING!
Does not works in Rails 2!
Error500: undefined local variable or method `view_class’ for HomeController:Class
A plugin from cuzic
This plugin enables you to deploy your rails application behind reverse proxy which does not rewrite link url appropriately.
The concept is very simple. The return value of `url_for’ is a relative path when your controller includes RelativePath.
# ============ # = usage 1 = # ============ # in app/controllers/application.rb class ApplicationController include RelativePath end
In the case of usage 1, Relative Path Plugin affects all over your
rails controllers. All `url_for’s generates relative paths not
absolute paths.
# ============ # = usage 2 = # ============ # in app/controllers/foo_controller.rb class FooController < ApplicationController include RelativePath end
In the case of usage 2, Relative Path Plugin affects only FooController.
`url_for’ in FooController generates relative paths not absolute paths.
FAQ.
(Q) Does `url_for’ mean ActionController::Base#url_for and ActionView::Helpers::UrlHelper#url_for ?
(A) Yes! Relative Path Plugin redefines both `url_for’s. You can invoke relative path version of `url_for’ in both controllers and view templates.
(Q) Does Relative Path Plugin rewrite url of `redirect_to’ ?
(A) Yes! This plugin works even if your application uses `redirect_to’.
(Q) Doesn’t relative path redirection violate RFC?
(A) Ohhhh… . It’s true that RFC says location header field
consists of a single absolute URI.
But almost all web browsers accept a relative path as a
location header field. Some kinds of situations need a relative path
even for a location header. I believe it is OK to use a relative path
for a location header field.
(Q) When redirecting, WEBrick corrects location header field, doesn’t it?
(A) Yes! So Relative Path plugin disables the correction feature
of WEBrick when you use WEBrick. While your controller includes RelativePath,
the behavior of WEBrick is changed.
(Q) Login generator needs absolute path to send a mail. Can `url_for’ generate absolute path even if my controller includes RelativePath ?
(A) Yes! try this:
with_relative_path_disabled do url_for(:controller => 'your_controller',:action => 'your_action',:only_path => false) end
contact information: cuzic atmark cuzic.com
svn: http://opensvn.csie.org/relative_path/tags/relative_path
WARNING!
Does not works in Rails 2!
Error500: undefined local variable or method `view_class’ for HomeController:Class
A plugin from cuzic
This plugin enables you to deploy your rails application behind reverse proxy which does not rewrite link url appropriately.
The concept is very simple. The return value of `url_for’ is a relative path when your controller includes RelativePath.
# ============ # = usage 1 = # ============ # in app/controllers/application.rb class ApplicationController include RelativePath end
In the case of usage 1, Relative Path Plugin affects all over your
rails controllers. All `url_for’s generates relative paths not
absolute paths.
# ============ # = usage 2 = # ============ # in app/controllers/foo_controller.rb class FooController < ApplicationController include RelativePath end
In the case of usage 2, Relative Path Plugin affects only FooController.
`url_for’ in FooController generates relative paths not absolute paths.
FAQ.
(Q) Does `url_for’ mean ActionController::Base#url_for and ActionView::Helpers::UrlHelper#url_for ?
(A) Yes! Relative Path Plugin redefines both `url_for’s. You can invoke relative path version of `url_for’ in both controllers and view templates.
(Q) Does Relative Path Plugin rewrite url of `redirect_to’ ?
(A) Yes! This plugin works even if your application uses `redirect_to’.
(Q) Doesn’t relative path redirection violate RFC?
(A) Ohhhh… . It’s true that RFC says location header field
consists of a single absolute URI.
But almost all web browsers accept a relative path as a
location header field. Some kinds of situations need a relative path
even for a location header. I believe it is OK to use a relative path
for a location header field.
(Q) When redirecting, WEBrick corrects location header field, doesn’t it?
(A) Yes! So Relative Path plugin disables the correction feature
of WEBrick when you use WEBrick. While your controller includes RelativePath,
the behavior of WEBrick is changed.
(Q) Login generator needs absolute path to send a mail. Can `url_for’ generate absolute path even if my controller includes RelativePath ?
(A) Yes! try this:
with_relative_path_disabled do url_for(:controller => 'your_controller',:action => 'your_action',:only_path => false) end
contact information: cuzic atmark cuzic.com
svn: http://opensvn.csie.org/relative_path/tags/relative_path