diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-13 11:35:48 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-13 11:35:48 +0000 |
commit | 922f817a5a369adc8cb0dd53f332785ee20a667a (patch) | |
tree | 8a0cf0b51e59e9fe35a12938a198b436ecc65212 /actionpack/lib/action_controller/url_rewriter.rb | |
parent | 0cce17f811a7e5217e667b40c44f788e3559f790 (diff) | |
download | rails-922f817a5a369adc8cb0dd53f332785ee20a667a.tar.gz rails-922f817a5a369adc8cb0dd53f332785ee20a667a.tar.bz2 rails-922f817a5a369adc8cb0dd53f332785ee20a667a.zip |
Added the option of passing false to :module or :controller_prefix in order to "break out" of a module or prefix
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@142 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/url_rewriter.rb')
-rw-r--r-- | actionpack/lib/action_controller/url_rewriter.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/url_rewriter.rb b/actionpack/lib/action_controller/url_rewriter.rb index 78638da39e..493e4911c6 100644 --- a/actionpack/lib/action_controller/url_rewriter.rb +++ b/actionpack/lib/action_controller/url_rewriter.rb @@ -12,7 +12,7 @@ module ActionController validate_options(VALID_OPTIONS, options.keys) rewrite_url( - rewrite_path(@rewritten_path, options), + rewrite_path(@rewritten_path, resolve_aliases(options)), options ) end @@ -30,8 +30,13 @@ module ActionController unknown_option_keys = supplied_option_keys - valid_option_keys raise(ActionController::ActionControllerError, "Unknown options: #{unknown_option_keys}") unless unknown_option_keys.empty? end + + def resolve_aliases(options) + options[:controller_prefix] = options[:module] unless options[:module].nil? + options + end - def rewrite_url(path, options) + def rewrite_url(path, options) rewritten_url = "" rewritten_url << @request.protocol unless options[:only_path] rewritten_url << @request.host_with_port unless options[:only_path] @@ -122,9 +127,14 @@ module ActionController end def controller_name(options, controller_prefix) - options[:controller_prefix] = "#{options[:module]}/#{options[:controller_prefix]}" if options[:module] ensure_slash_suffix(options, :controller_prefix) - controller_name = options[:controller_prefix] || controller_prefix || "" + + controller_name = case options[:controller_prefix] + when String: options[:controller_prefix] + when false : "" + when nil : controller_prefix || "" + end + controller_name << (options[:controller] + "/") if options[:controller] return controller_name end |