Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

This patch modifies RouteSet#write_generation and RouteSet#write_reco…

…gnition 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
  • Loading branch information...
commit 96e590ca3c25e63d03c9ae5d74a40538cbe88f58 1 parent c92ecb8
@dhh dhh authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 actionpack/lib/action_controller/routing.rb
View
9 actionpack/lib/action_controller/routing.rb
@@ -388,6 +388,7 @@ def generate_default_path(*args)
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 @@ def write_generation
method_name = "generate_path_for_#{ivar}".to_sym
instance_variable_set "@#{ivar}", routes
code = generation_code_for(ivar, method_name).to_s
+ method_sources &lt;&lt; code
filename = "generated_code/routing/generation_for_controller_#{controller}.rb"
eval(code, nil, filename)
@@ -404,7 +406,11 @@ def write_generation
@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 &lt;&lt; code)
end
def recognize(request)
@@ -439,6 +445,7 @@ def write_recognition
end
eval g.to_s, nil, 'generated/routing/recognition.rb'
+ return g.to_s
end
def generation_code_for(ivar = 'routes', method_name = nil)
Please sign in to comment.
Something went wrong with that request. Please try again.