A talk about the presenter pattern in Rails and an introduction to the gem Draper
Ruby JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
db
lib/tasks
public
script
slides
spec
test
vendor/plugins
.gitignore
Gemfile
Gemfile.lock
README.markdown
Rakefile
config.ru

README.markdown

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
    1. Show how to add it to the project
    2. Clean up the view bit by bit
    3. Show off some fancy tricks
    4. Fast-forward to the clean view code
  5. End frontal presentation - start open talk
    1. Summarize the benefits
    2. Ask for experiences
    3. Start discussion about pros and cons
    4. Ask the crowd if they see benefits for testing
  6. 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