This will become a collection for a talk about the presenter pattern in Rails and using the example of the gem Draper.
- Reception
- Introduce the presenter pattern
- Do it in theory
- Explain the benefits
- Show some view code of a normal Rails project
- 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