Skip to content

Instantly share code, notes, and snippets.

@Eth3rnit3
Created September 4, 2019 20:21
Show Gist options
  • Save Eth3rnit3/aabf927d45e7973182374f47f7244e1f to your computer and use it in GitHub Desktop.
Save Eth3rnit3/aabf927d45e7973182374f47f7244e1f to your computer and use it in GitHub Desktop.
class Upload < ApplicationRecord
has_one_attached :file
after_create :build_url
private
def build_url
update_column(:url, Rails.application.routes.url_helpers.rails_blob_path(file, only_path: true)) if file.attached?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment