diff options
Diffstat (limited to 'app/models/route.rb')
-rw-r--r-- | app/models/route.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/route.rb b/app/models/route.rb index 41e6eb7cb73..4b3efab5c3c 100644 --- a/app/models/route.rb +++ b/app/models/route.rb @@ -10,9 +10,11 @@ class Route < ActiveRecord::Base after_update :rename_descendants + scope :inside_path, -> (path) { where('routes.path LIKE ?', "#{sanitize_sql_like(path)}/%") } + def rename_descendants if path_changed? || name_changed? - descendants = Route.where('path LIKE ?', "#{path_was}/%") + descendants = self.class.inside_path(path_was) descendants.each do |route| attributes = {} |