def flash_danger(resource, action = nil, e: nil, name: nil)
      raise 'expected an ActiveRecord resource' unless resource.respond_to?(:errors) && (name || resource.class.respond_to?(:model_name))

      action ||= resource.respond_to?(:new_record?) ? (resource.new_record? ? :create : :update) : :save
      action = action.to_s.gsub('_', ' ')

      messages = flash_errors(resource, e: e)

      name ||= resource.to_s.presence

      ["Unable to #{action}", (" #{name}" if name), (": #{messages}" if messages)].compact.join.html_safe
    end
def flash_danger(resource, action = nil, e: nil, name: nil)
      raise 'expected an ActiveRecord resource' unless resource.respond_to?(:errors) && (name || resource.class.respond_to?(:model_name))

      action ||= resource.respond_to?(:new_record?) ? (resource.new_record? ? :create : :update) : :save
      action = action.to_s.gsub('_', ' ')

      messages = flash_errors(resource, e: e)

      name ||= resource.to_s.presence

      ["Unable to #{action}", (" #{name}" if name), (": #{messages}" if messages)].compact.join.html_safe
    end
flash.now[:danger] = flash_danger(@post)