From 0d67c19520bda94c1cc7846330269c16ee4ed752 Mon Sep 17 00:00:00 2001 From: rohit Date: Sun, 1 Aug 2010 15:54:35 +0530 Subject: [PATCH] Use non-regexp sentinel to avoid using a group as it confuses Thor. [#5263 state:resolved] --- railties/lib/rails/generators/actions.rb | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 2280cc1..c76bc6b 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -277,6 +277,12 @@ module Rails log :route, routing_code sentinel = /\.routes\.draw do(\s*\|map\|)?\s*$/ + # TODO: The following logic should be removed when the deprecated router is removed + if File.exist?("config/routes.rb") + match = sentinel.match(File.read("config/routes.rb")) + sentinel = match && match[1] ? "routes.draw do |map|" : "routes.draw do" + end + in_root do inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false } end -- 1.7.0.4