You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: attachment.rb
    path of file: ./repos/onebody/app/models
    
    the code of the file until where you have to start completion: class Attachment < ApplicationRecord
  include Concerns::FileImage

  include Authority::Abilities
  self.authorizer_name = 'AttachmentAuthorizer'

  belongs_to :message, optional: true

    
    def create_from_file(attributes)
      file = attributes[:file]
      attributes[:name] = File.split(file.original_filename).last
      attributes[:content_type] = file.content_type
      create(attributes).tap do |attachment|
        if attachment.valid?
          attachment.file = file
          attachment.errors.add(:base, 'File could not be saved.') unless attachment.file.exists?
        end
      end