draper icon indicating copy to clipboard operation
draper copied to clipboard

ActiveStorage decorators

Open mkamensky opened this issue 6 years ago • 3 comments

I suggest including support for decorating ActiveStorage attachment. Since ActiveStorage does not derive from ActiveRecord, this is not automatic. I currently do it by putting

Draper.setup_orm(ActiveStorage::Attached)

in a initializer. Thanks!

mkamensky avatar May 08 '19 13:05 mkamensky

Thanks for the suggestion!

It would be highly appreciated if you provided some examples and use cases that demonstrate this as a generic feature a regular app could benefit of.

Alexander-Senko avatar Sep 04 '24 12:09 Alexander-Senko

Thanks for the suggestion!

It would be highly appreciated if you provided some examples and use cases that demonstrate this as a generic feature a regular app could benefit of.

Sorry for the delay. I use it, for example, to generate various html snippets (for instance image tags in active_storage/blob_decorator.rb), to set to_partial_path, to return its url, etc.

mkamensky avatar Oct 30 '24 07:10 mkamensky

@mkamensky, thanks for the reply.

While your solution works technically, I'd like to be sure the implemented pattern is quite generic to be supported out of the box.

Could you please provide close to real life usage examples for decorated objects? One thing of a particular interest for me is the rendering context: are they rendered in views or some other places?

Unfortunately, Draper is hard to develop now due to lack of maintainers needed to review the changes. I tried to fix as many things as possible without a major refactoring then. Meanwhile, I consider Draper to be bloated with legacy stuff and cumbersome solutions that make it hard to develop while maintaining backward compatibility.

I was considering a refactoring of Draper for the next major release, but then I developed 3 gems to replace it:

That's why I'm asking for your use cases. I'd like to consider supporting them in my libs too.

Alexander-Senko avatar Oct 31 '24 14:10 Alexander-Senko