diff options
| author | Zog | 2018-04-19 10:02:12 +0200 | 
|---|---|---|
| committer | Zog | 2018-04-19 10:02:12 +0200 | 
| commit | bd12c492cae0ee3fc91b8ee0fdb5fc4f790fe994 (patch) | |
| tree | ec13bad7af495c43b807abe2bcae8a49e66b5de5 | |
| parent | ca0a4907e5714d6f56ede8d47f2514cdd2752e2f (diff) | |
| download | chouette-core-6573-fix-checksums-update-task.tar.bz2 | |
Refs #6573; Fix task6573-fix-checksums-update-task
Force-load all models beforehand
| -rw-r--r-- | app/models/referential.rb | 46 | ||||
| -rw-r--r-- | lib/tasks/referential.rake | 2 | 
2 files changed, 23 insertions, 25 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index 1794126a2..78b719fab 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -78,31 +78,29 @@ class Referential < ApplicationModel    alias_method_chain :save, :table_lock_timeout -  if Rails.env.development? -    def self.force_register_models_with_checksum -      paths = Rails.application.paths['app/models'].to_a -      Rails.application.railties.each do |tie| -        next unless tie.respond_to? :paths -        paths += tie.paths['app/models'].to_a -      end +  def self.force_register_models_with_checksum +    paths = Rails.application.paths['app/models'].to_a +    Rails.application.railties.each do |tie| +      next unless tie.respond_to? :paths +      paths += tie.paths['app/models'].to_a +    end -      paths.each do |path| -        next unless File.directory?(path) -        Dir.chdir path do -          Dir['**/*.rb'].each do |src| -            next if src =~ /^concerns/ -            # thanks for inconsistent naming ... -            if src == "route_control/zdl_stop_area.rb" -              RouteControl::ZDLStopArea -              next -            end -            Rails.logger.info "Loading #{src}" -            begin -              src[0..-4].classify.safe_constantize -            rescue => e -              Rails.logger.info "Failed: #{e.message}" -              nil -            end +    paths.each do |path| +      next unless File.directory?(path) +      Dir.chdir path do +        Dir['**/*.rb'].each do |src| +          next if src =~ /^concerns/ +          # thanks for inconsistent naming ... +          if src == "route_control/zdl_stop_area.rb" +            RouteControl::ZDLStopArea +            next +          end +          Rails.logger.info "Loading #{src}" +          begin +            src[0..-4].classify.safe_constantize +          rescue => e +            Rails.logger.info "Failed: #{e.message}" +            nil            end          end        end diff --git a/lib/tasks/referential.rake b/lib/tasks/referential.rake index d53157312..b3202035b 100644 --- a/lib/tasks/referential.rake +++ b/lib/tasks/referential.rake @@ -70,7 +70,7 @@ namespace :referential do    def update_checksums_for_referential referential      thing = %w(\\ | / —) -    Referential.force_register_models_with_checksum if Rails.env.development? && Referential.models_with_checksum.empty? +    Referential.force_register_models_with_checksum      puts "\n \e[33m***\e[0m Referential #{referential.name}"      referential.switch do        Referential.models_with_checksum.each do |klass| | 
