RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Magic Presenter: A modern replacement for Draper

Magic Presenter is a presentation layer gem for Rails models designed to replace Draper. It retains the Decorator/Presenter pattern while addressing fundamental architectural flaws and design bottlenecks present in Draper.

Key issues solved

Draper’s architecture relies on internal monkey-patches and request-caching mechanisms that lead to persistent failure modes in modern Rails applications:

  • View Context Instability & Thread-Safety: Eliminates stateful view-context caching and thread-local storage hacks. Resolves recurring NoMethodError issues (nil host/url_options) during route generation inside decorators.
  • Delegation & Object Identity Pitfalls: Fixes proxy wrapper edge cases where equality checking (==), is_a?, kind_of?, and method delegation break expected Ruby object semantics.
  • Collection & Relation Degradation: Prevents losing ActiveRecord relation scopes, chaining capabilities, and pagination wrappers (Kaminari/WillPaginate) when decorating collections or associations.
Architecture & magic features

Magic Presenter is built from scratch for modern Ruby and Rails environments without legacy compatibility workarounds.

  • Automatic Class Inference: Infers and instantiates the correct presenter class for an object or collection automatically.
  • Implicit Association & Collection Presenting: Dynamically decorates associations and nested object graphs as they are accessed.
  • Decoupled View Context: Propagates view context cleanly through explicit, lightweight mechanics rather than hooking deeply into controller request cycles.

Repository: https://github.com/Alexander-Senko/magic-presenter/

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in