Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Rails
  3. draper

draper

MITRubyv4.0.6

A decorator/view-model library for Rails applications that adds an object-oriented layer of presentation logic.

GitHubGitHub
5.3k stars523 forks0 contributors

What is draper?

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.

Target Audience

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.

Value Proposition

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.

Overview

Decorators/View-Models for Rails Applications

Use Cases

Best For

  • Moving complex view logic out of Rails helpers into reusable classes
  • Adding presentation methods to models without polluting ActiveRecord classes
  • Formatting data for display (dates, names, URLs) in a centralized way
  • Testing presentation logic in isolation from models and views
  • Decorating collections and associated objects in Rails applications
  • Integrating with pagination gems like Kaminari or will_paginate

Not Ideal For

  • Applications with minimal view logic where Rails helpers are sufficient without added abstraction
  • Projects using modern frontend frameworks like React or Vue.js that handle presentation entirely on the client side
  • Teams already using ViewComponent or similar patterns that encapsulate view logic in reusable components
  • Performance-critical APIs or services where object decoration overhead could impact response times

Pros & Cons

Pros

Object-Oriented Design

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.

Seamless Rails Integration

Works tightly with ActiveRecord, supporting decoration of collections, associations, and pagination gems like Kaminari, reducing boilerplate in controllers and views.

Built-in Testing Support

Includes matchers for RSpec, MiniTest, and Test::Unit, such as `be_decorated`, allowing easy verification of decorated objects in controller specs.

Flexible Delegation

Offers `delegate_all` for full method access or selective delegation to control which model methods are exposed, enhancing clarity and security in views.

Cons

Abstraction Overhead

Introduces an extra layer of decorator classes that developers must manage, increasing complexity and learning curve, especially for teams new to the pattern.

Performance Trade-offs

Decorator instantiation for each model object can lead to higher memory usage and slower performance, particularly with large collections or high-throughput applications.

Rails-Centric Limitations

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.

Maintenance Burden

As applications scale, managing numerous decorator classes can become cumbersome, risking code duplication or bloated decorators if not carefully disciplined.

Frequently Asked Questions

Quick Stats

Stars5,274
Forks523
Contributors0
Open Issues20
Last commit10 days ago
CreatedSince 2011

Tags

#object-oriented-design#decorator-pattern#decorators#ruby-gem#testing#mvc-architecture#active-record#ruby-on-rails#presentation-layer#ruby#rails-helpers

Built With

R
Rails
R
Ruby
A
ActiveRecord

Included in

Ruby14.1kRails3.9k
Auto-fetched 1 day ago

Related Projects

devisedevise

Flexible authentication solution for Rails with Warden.

Stars24,355
Forks5,490
Last commit1 month ago
spreespree

Open-source headless eCommerce platform with REST API, TypeScript SDK, and Next.js storefront for cross-border, B2B or marketplace eCommerce.

Stars15,461
Forks5,264
Last commit1 day ago
activeadminactiveadmin

The administration framework for Ruby on Rails applications.

Stars9,699
Forks3,327
Last commit1 day ago
CarrierwaveCarrierwave

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks

Stars8,787
Forks1,646
Last commit16 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub