alexs333
alexs333

Reputation: 12593

ActiveStorage - retrieving file URL

I am migrating from deprecated paperclip gem to ActiveStorage and wondering how can I get hold of attachment URL in the model (for example if I want to add it to custom as_json method, some elasticshearh data etc.)

Couldn't find anything in documentation for that particular use case.

Upvotes: 2

Views: 2121

Answers (1)

Rashid D R
Rashid D R

Reputation: 160

file = fetch_your_file

link = rails_blob_path(file, disposition: 'attachment') 

will return the attachment link

Upvotes: 2

Related Questions