def flash_errors(resource, e: nil)
      raise 'expected an ActiveRecord resource' unless resource.respond_to?(:errors)

      messages = resource.errors.map do |attribute, message|
        if message[0] == message[0].upcase # If the error begins with a capital letter
          message
        elsif attribute == :base
          message
        elsif attribute.to_s.end_with?('_ids')
          "#{resource.class.human_attribute_name(attribute.to_s[0..-5].pluralize).downcase} #{message}"
        else
          "#{resource.class.human_attribute_name(attribute).downcase} #{message}"
        end
      end

      messages << e.message if messages.blank? && e && e.respond_to?(:message)

      messages.to_sentence.presence
    end
def flash_errors(resource, e: nil)
      raise 'expected an ActiveRecord resource' unless resource.respond_to?(:errors)

      messages = resource.errors.map do |attribute, message|
        if message[0] == message[0].upcase # If the error begins with a capital letter
          message
        elsif attribute == :base
          message
        elsif attribute.to_s.end_with?('_ids')
          "#{resource.class.human_attribute_name(attribute.to_s[0..-5].pluralize).downcase} #{message}"
        else
          "#{resource.class.human_attribute_name(attribute).downcase} #{message}"
        end
      end

      messages << e.message if messages.blank? && e && e.respond_to?(:message)

      messages.to_sentence.presence
    end
flash.now[:danger] = "Unable to accept: #{flash_errors(@post)}"