[feature][ActiveStorage] default file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[feature][ActiveStorage] default file

Hamad Al-Ghanim

i have just recently migrated from paperclip to active storage and one of the differences that i noticed is that active storage doesn't provide a way to have a default file. i think that adding a helper method is inconvenient for each model and default file, and checking for the file if it is attached is also an issue that makes view files larger than it should

previously we could have a default behavior on paperclip using the following in our model:


  has_attached_file :avatar, default_url: "/images/:style/missing.png"


i am proposing following to be used for active storage, however if this cannot be done and someone has a better spec please comment away.


   has_one_attached :avatar, default_file: "/images/:style/missing.png" # or somewhere from assets


for obvious reasons this shouldn't work onĀ has_many_attached

i hope this is the correct channel for such an issue, if it is not please provide me with the correct one

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.