I think this would be a great feature to have. Looking around the code I find that one main issue is that doing attribute assignment like `@record.file=attachable` uploads the attachable to the service right away. We could make it so that `ActiveStorage::Attached` stores the attachable as an instance variable and a new method called `attach!` actually uploads the file. Then one could validate that `file.content_type` is valid. On Monday, April 2, 2018 at 8:36:22 AM UTC-5, Matt Yanchek wrote: > > Hey all, with ActiveStorage coming out very soon I am very quickly finding > a need for some validations for attachments before storing. Some very quick > validation helpers would be great for example content type and size would > be huge wins in protecting an application that is expecting to only allow > images. > > Just a quick example: > > class User < ApplicationRecord > has_one_attached :avatar > > validates :avatar, attachment: { content_types: 'image/*', size: 50 } > end > >
-- 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 rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.