Skip to content

Instantly share code, notes, and snippets.

@dwilkie
Last active May 17, 2023 20:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwilkie/3173f091c784d266e1081fb90bbc37b4 to your computer and use it in GitHub Desktop.
Save dwilkie/3173f091c784d266e1081fb90bbc37b4 to your computer and use it in GitHub Desktop.
Migrate from Refile to ActiveStorage
CallDataRecord.find_each do |cdr|
next if cdr.file.attached?
cdr_url = "https://s3-ap-southeast-1.amazonaws.com/cdr.somleng.org/store/#{cdr.file_id}"
cdr.file.attach(
io: open(cdr_url),
filename: cdr.file_filename,
content_type: cdr.file_content_type
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment