lib/jets/commands/upgrade.rb in jets-2.1.0 vs lib/jets/commands/upgrade.rb in jets-2.1.1

- old
+ new

@@ -12,10 +12,11 @@ Version1.new.run # version 2 upgrades inject_csrf_meta_tags update_crud_js update_config_application_rb + update_autoload_paths_config puts "Upgrade complete." end def inject_csrf_meta_tags layout = "app/views/layouts/application.html.erb" @@ -72,8 +73,33 @@ end content = lines.join IO.write(app_rb, content) puts "Update: #{app_rb} with default_protect_from_forgery" + end + + def update_autoload_paths_config + app_rb = "config/application.rb" + lines = IO.readlines(app_rb) + + new_config = lines.find { |l| l.include?('config.autoload_paths') } + return if new_config + + old_config = lines.find { |l| l.include?('config.extra_autoload_paths') } + return unless old_config + + lines.map! do |line| + md = line.match(/config\.extra_autoload_paths(.*)/) + if md + rest = md[1] + " config.autoload_paths#{rest}" + else + line + end + end + + content = lines.join + IO.write(app_rb, content) + puts "Update: #{app_rb} with config.autoload_paths" end end end