Permalink
Browse files

Incorporated a fix to insert_routes from mainline

  • Loading branch information...
1 parent 628aefd commit 3fea18f17c13bbabf01cd362878b834db14d60f9 Philip (flip) Kromer committed Aug 12, 2008
Showing with 15 additions and 10 deletions.
  1. +1 −0 .gitignore
  2. +14 −10 generators/lib/insert_routes.rb
View
@@ -18,3 +18,4 @@ actionmailer_config_DONOTVERSION.rb
/coverage
/doc/app
/doc/plugins
+/away
@@ -11,13 +11,13 @@ def route_resource(*resources)
end
end
- def route_name(name, path, options = {})
+ def route_name(name, path, route_options = {})
sentinel = 'ActionController::Routing::Routes.draw do |map|'
- logger.route "map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'"
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
unless options[:pretend]
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
- "#{match}\n map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'"
+ "#{match}\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
end
end
end
@@ -28,12 +28,16 @@ def route_resource(*resources)
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
look_for = "\n map.resource #{resource_list}\n"
logger.route "map.resource #{resource_list}"
- gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
+ unless options[:pretend]
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
+ end
end
- def route_name(name, path, options = {})
- look_for = "\n map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'"
- logger.route "map.#{name} '#{path}', :controller => '#{options[:controller]}', :action => '#{options[:action]}'"
- gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
+ def route_name(name, path, route_options = {})
+ look_for = "\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
+ unless options[:pretend]
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
+ end
end
end
@@ -42,7 +46,7 @@ def route_resource(*resources)
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
logger.route "map.resource #{resource_list}"
end
- def route_name(name, path, options = {})
- logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'"
+ def route_name(name, path, route_options = {})
+ logger.route "map.#{name} '#{path}', :controller => '{route_options[:controller]}', :action => '#{route_options[:action]}'"
end
end

0 comments on commit 3fea18f

Please sign in to comment.