Skip to content

Instantly share code, notes, and snippets.

@craigmcnamara
Created June 23, 2020 23:03
Show Gist options
  • Save craigmcnamara/3cacc519d0c26179a919b658617c3f77 to your computer and use it in GitHub Desktop.
Save craigmcnamara/3cacc519d0c26179a919b658617c3f77 to your computer and use it in GitHub Desktop.
An example of setting up an ActiveStorage attachment
FactoryBot.define do
factory :thing do
after(:build) do |thing, evaluator|
file_path = Rails.root.join('spec/fixtures/files/image-needs-auto-orient.jpg')
thing.photos.attach(io: File.open(file_path), filename: 'photo.jpg')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment