A decorator/view-model library for Rails applications that adds an object-oriented layer of presentation logic.
Draper is a Ruby gem that adds decorators (view models) to Rails applications. It provides an object-oriented way to handle presentation logic by wrapping models with decorator classes, separating view concerns from business logic. It solves the problem of tangled helper methods and bloated models by organizing presentation code into testable, reusable decorators.
Rails developers who want to clean up their view layer by moving presentation logic out of helpers and models. It's particularly useful for teams building maintainable applications with complex view requirements.
Developers choose Draper because it replaces procedural Rails helpers with object-oriented decorators, making presentation logic easier to organize, test, and reuse. Its seamless integration with Rails conventions and support for collections and associations makes it a natural fit for Rails applications.
Decorators/View-Models for Rails Applications
Replaces procedural Rails helpers with decorator classes, making view logic more organized and testable, as demonstrated by moving methods like `publication_status` out of global helpers.
Works tightly with ActiveRecord, supporting decoration of collections, associations, and pagination gems like Kaminari, reducing boilerplate in controllers and views.
Includes matchers for RSpec, MiniTest, and Test::Unit, such as `be_decorated`, allowing easy verification of decorated objects in controller specs.
Offers `delegate_all` for full method access or selective delegation to control which model methods are exposed, enhancing clarity and security in views.
Introduces an extra layer of decorator classes that developers must manage, increasing complexity and learning curve, especially for teams new to the pattern.
Decorator instantiation for each model object can lead to higher memory usage and slower performance, particularly with large collections or high-throughput applications.
Tightly coupled with Rails conventions and ActiveRecord, making it less suitable for non-Rails projects or those using alternative ORMs without additional configuration, as noted with Mongoid support.
As applications scale, managing numerous decorator classes can become cumbersome, risking code duplication or bloated decorators if not carefully disciplined.
Flexible authentication solution for Rails with Warden.
Open-source headless eCommerce platform with REST API, TypeScript SDK, and Next.js storefront for cross-border, B2B or marketplace eCommerce.
The administration framework for Ruby on Rails applications.
Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.