Callbackify autoload! since it is empty and fixes a but (forgotten in a controller)

This commit is contained in:
2018-05-05 18:36:53 -03:00
parent 0e2f40fc4b
commit a9c9d0dc39
3 changed files with 5 additions and 7 deletions
+2 -2
View File
@@ -35,8 +35,8 @@ $ ->
try
HawkEye.add_general_configuration
facet:
state:
colors:
colors:
state:
uncategorized: "#eee"
unplanned: "#aaa"
planned: "#99b"
@@ -27,7 +27,7 @@ class Dunlop::SourceFilesController < Dunlop::ApplicationController
redirect_to source_files_path, alert: "No type specified" and return unless params[:source_file][:sti_type].present?
authorize! :manage, @source_file
@source_file.creator = current_user
@source_file.save && @source_file.autoload!
@source_file.save
redirect_to source_files_path
end
+2 -4
View File
@@ -4,6 +4,7 @@ module Dunlop::SourceFileModel
if attachment.persisted?
{}
else
# This strategy fails when the original_file of a model is changed. But is for here no usecase
{'Content-Disposition' => %|attachment; filename="#{attachment.pre_set_original_file&.original_filename.presence || attachment.class.name + Time.now.getutc.iso8601}"|}
end
end
@@ -31,6 +32,7 @@ module Dunlop::SourceFileModel
event(:failed) { transition any => :failed }
end
after_create { autoload! }
end
def deactivate_loaded_source_file
@@ -213,10 +215,6 @@ module Dunlop::SourceFileModel
end
alias_method :load_scheduled!, :load_scheduled_source_files
def for_select
classes.map{|klass| [klass.model_name.human, klass.name]}
end
def has_panda_original_file(options = {})
environments = Array.wrap(options.delete(:environments)) || %w[production staging]
if environments.include?(Rails.env)