From 1c59ffca5c8e998aa5cfc0abb594981de23e64c8 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 3 Feb 2015 22:47:59 +0000 Subject: Don't remove all line endings from routes.rb When there is a single scaffold in the routes.rb with no other lines then revoking/destroying it will create a routes.rb file with a syntax error. This is because the sentinel for the Thor `route` action didn't include the newline but the logged route code did. The fix is to add the newline to the sentinel and remove it from the the logged route code. Fixes #15913. --- railties/lib/rails/generators/actions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index e35015f630..e39a45f4c9 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -218,10 +218,10 @@ module Rails # route "root 'welcome#index'" def route(routing_code) log :route, routing_code - sentinel = /\.routes\.draw do\s*$/ + sentinel = /\.routes\.draw do\s*\n/m in_root do - inject_into_file 'config/routes.rb', "\n #{routing_code}", { after: sentinel, verbose: false } + inject_into_file 'config/routes.rb', " #{routing_code}", { after: sentinel, verbose: false } end end -- cgit v1.2.3