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)
- Reception to 'kill your helpers'
- Show some view code of a normal Rails project
- Introducing the decorator pattern
- Introduce the gem Draper
- Show how to add it to the project
- Clean up the view bit by bit
- Show off some fancy tricks
- Fast-forward to the clean view code
- End frontal presentation - start open talk
- Summarize the benefits
- Ask for experiences
- Start discussion about pros and cons
- Ask the crowd if they see benefits for testing
- Thank everybody
This gem makes it easy to apply the decorator pattern to domain models in a Rails application. This pattern gives you three wins:
- Replace most helpers with an object-oriented approach
- Filter data at the presentation level
- Enforce an interface between your controllers and view templates.
Ryan Bates has put together an excellent RailsCast on Draper based on the 0.8.0 release:
And he did a Pro RailsCast on implementing the presenter pattern from scratch: RailsCast #287