From 9bf9e6eb38b955791abce475dbaec1001d6c39c0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 20 Mar 2017 19:17:14 -0400 Subject: Handle Route#name being nil after an update It was possible for the `routes.name` field to be `NULL`, causing `name_was` to be `nil` after a rename, resulting a bad first argument to `sub` when attempting to rename descendants. This change adds a condition to make sure `name_was` is present before attempting the descendant update. --- app/models/route.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/route.rb b/app/models/route.rb index 73574a6206b..41e6eb7cb73 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -21,7 +21,7 @@ class Route < ActiveRecord::Base attributes[:path] = route.path.sub(path_was, path) end - if name_changed? && route.name.present? + if name_changed? && name_was.present? && route.name.present? attributes[:name] = route.name.sub(name_was, name) end -- cgit v1.2.1