diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-28 17:17:39 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-28 17:17:39 +0000 |
commit | 96e590ca3c25e63d03c9ae5d74a40538cbe88f58 (patch) | |
tree | 00a8acf86dbdae5a65281818451509c887959423 | |
parent | c92ecb82b816df530b43f7334e1ad80beeac3f4c (diff) | |
download | rails-96e590ca3c25e63d03c9ae5d74a40538cbe88f58.tar.gz rails-96e590ca3c25e63d03c9ae5d74a40538cbe88f58.tar.bz2 rails-96e590ca3c25e63d03c9ae5d74a40538cbe88f58.zip |
This patch modifies RouteSet#write_generation and RouteSet#write_recognition so that they return the source code used to recognize or generate URLs. #1531 [Nicholas Seckar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1551 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index 27f651da51..7df25dba0f 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -388,6 +388,7 @@ module ActionController end def write_generation + method_sources = [] @generation_methods = Hash.new(:generate_default_path) categorize_routes.each do |controller, routes| next unless routes.length < @routes.length @@ -396,6 +397,7 @@ module ActionController method_name = "generate_path_for_#{ivar}".to_sym instance_variable_set "@#{ivar}", routes code = generation_code_for(ivar, method_name).to_s + method_sources << code filename = "generated_code/routing/generation_for_controller_#{controller}.rb" eval(code, nil, filename) @@ -404,7 +406,11 @@ module ActionController @generation_methods[controller.to_sym] = method_name end - eval(generation_code_for('routes', 'generate_default_path').to_s, nil, 'generated_code/routing/generation.rb') + + code = generation_code_for('routes', 'generate_default_path').to_s + eval(code, nil, 'generated_code/routing/generation.rb') + + return (method_sources << code) end def recognize(request) @@ -439,6 +445,7 @@ module ActionController end eval g.to_s, nil, 'generated/routing/recognition.rb' + return g.to_s end def generation_code_for(ivar = 'routes', method_name = nil) |