I had a similar need -- in my case I want to insert a cover letter at page 
1 of a PDF attachment -- and I came up with this:

https://gist.github.com/benwalsh/d611608ea9f4ff6e1ec1efd0d3755b37 

In the model, then:

include ActiveStorageCallbacks 

perform_attach welcome_pack: { before: :insert_cover_letter }


 
I tried a more sophisticated approach that injected the custom callback 
into the callback chain but it was hard so I gave up.




On Monday, 20 May 2019 20:57:36 UTC+1, Tom Rossi wrote:
>
> I'm not sure how common this is, but wondering if its worth working on a 
> PR for ActiveStorage to allow you to use callbacks. Something like this for 
> example to run a method after analyze is complete:
>
> has_one_attached :artwork, after_analyze: :my_method
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-core/f42eba14-2be0-4c6c-bce5-319ed32043cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to