app/controllers/avo/actions_controller.rb in avo-2.5.2.pre.6 vs app/controllers/avo/actions_controller.rb in avo-2.5.2.pre.7

- old
+ new

@@ -12,16 +12,18 @@ def handle resource_ids = action_params[:fields][:resource_ids].split(",") models = @resource.class.find_scope.find resource_ids - fields = action_params[:fields].except("resource_ids") + fields = action_params[:fields].select do |key, value| + key != "resource_ids" + end args = { fields: fields, current_user: _current_user, - resource: resource + resource: resource, } args[:models] = models unless @action.standalone performed_action = @action.handle_action(**args) @@ -45,47 +47,30 @@ @action = action_class.new(model: model, resource: resource, user: _current_user) end def respond(response) response[:type] ||= :reload - messages = get_messages response + response[:message_type] ||= :notice + response[:message] ||= I18n.t("avo.action_ran_successfully") if response[:type] == :download return send_data response[:path], filename: response[:filename] end respond_to do |format| format.html do - # Flash the messages collected from the action - messages.each do |message| - flash[message[:type]] = message[:body] - end - if response[:type] == :redirect path = response[:path] if path.respond_to? :call path = instance_eval(&path) end - redirect_to path + redirect_to path, "#{response[:message_type]}": response[:message] elsif response[:type] == :reload - redirect_back fallback_location: resources_path(resource: @resource) + redirect_back fallback_location: resources_path(resource: @resource), "#{response[:message_type]}": response[:message] end end end - end - - private - - def get_messages(response) - default_message = { - type: :info, - body: I18n.t("avo.action_ran_successfully") - } - - return [default_message] if response[:messages].blank? - - response[:messages] end end end