Skip to content

mediafinger/rails_presenter_with_draper

Repository files navigation

Rails Presenter with Draper

The code was used as example code to demonstrate the decorator pattern in Rails using the example of the gem Draper.

You will find all Slides we used for the presentation at the Railscamp Hamburg 2011 in the folder slides (PDF)

I updated the app to Rails 3.2.11 and draper 0.18.0 without checking, if it still works (sorry, if not)

Overview

  1. Reception to 'kill your helpers'
  2. Show some view code of a normal Rails project
  3. Introducing the decorator pattern
  4. Introduce the gem Draper
  5. Show how to add it to the project
  6. Clean up the view bit by bit
  7. Show off some fancy tricks
  8. Fast-forward to the clean view code
  9. End frontal presentation - start open talk
  10. Summarize the benefits
  11. Ask for experiences
  12. Start discussion about pros and cons
  13. Ask the crowd if they see benefits for testing
  14. Thank everybody

Goals

This gem makes it easy to apply the decorator pattern to domain models in a Rails application. This pattern gives you three wins:

  1. Replace most helpers with an object-oriented approach
  2. Filter data at the presentation level
  3. Enforce an interface between your controllers and view templates.

Where to go from here

Watch the RailsCasts

Ryan Bates has put together an excellent RailsCast on Draper based on the 0.8.0 release:

RailsCast #286

And he did a Pro RailsCast on implementing the presenter pattern from scratch: RailsCast #287

Check out the Interwebs

About

A talk about the presenter pattern in Rails and an introduction to the gem Draper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published