Hello all - Firstly, huge thanks to those who have worked on ActiveStorage so far. The library seems to be coming along nicely.
ActiveStorage currently allows you to define variants of an attachment as follows: ```ruby class User < ActiveRecord::Base has_one_attached :avatar # ... end user.avatar.variant(resize: "100x100>") user.avatar.variant(resize: "100x100>", caption: "foo") user.avatar.variant(resize: "200x200", rotate: "-90") ``` I'd like to propose the following functionality that lets users configure and pre-define variants. ```ruby class User < ActiveRecord::Base has_one_attached( :avatar, variants: { small: { resize: "100x100>" } small_captioned: { resize: "100x100>", caption: "foo" } medium_rotated: { resize: "200x200", rotate: "-90" } } ) # ... end user.avatar.variant(:small) user.avatar.variant(:small_captioned) user.avatar.variant(:medium_rotated) # Something not pre-definied user.avatar.variant(rotate: "120") ``` This is similar in concept to how existing attachment libraries (paperclip, carrierwave, etc...) have allowed definition and configuration of variants. It is true that this functionality can be mimicked outside of activestorage by having the developer maintain a manual mapping of key names to variant configurations. However, I believe this should be part of ActiveStorage directly because - 1. It leads to cleaner/more readable code (e.g. `user.avatar.variant(:small)` is easy to understand) 2. It keeps configuration consolidated inline with `has_one_attached`, which is similar to how options are already defined inline with `has_one`, ` has_many`, etc... 3. It's fully backward compatible with how variants are invoked right now and doesn't force you to use a particular approach. Would such a feature be accepted if I were to submit a pull request for it? Thank you! -- 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.