drapergem / draper

Decorators/View-Models for Rails Applications
MIT License
5.23k stars 527 forks source link

ActiveStorage decorators #854

Open mkamensky opened 5 years ago

mkamensky commented 5 years ago

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!

Alexander-Senko commented 2 months ago

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.

mkamensky commented 1 week ago

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.

Alexander-Senko commented 6 days ago

@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.