<commit_before># Draper: View Models for Rails

![TravisCI Build Status](https://secure.travis-ci.org/jcasimir/draper.png)

## Quick Start

1. Add `gem 'draper'` to your `Gemfile` and `bundle`
2. Run `rails g draper:decorator YourModel`
3. Edit `app/decorators/[your_model]_decorator.rb` using:
  1. `h` to proxy to Rails/application helpers like `h.current_user`
  2. `[your_model]` to access the wrapped object like `article.created_at`
4. Put common decorations in `app/decorators/application.rb`  
5. Wrap models in your controller with the decorator using:
  1. `.find` automatic lookup & wrap
    ex: `ArticleDecorator.find(1)`
  2. `.decorate` method with single object or collection, 
    ex: `ArticleDecorator.decorate(Article.all)`
  3. `.new` method with single object
    ex: `ArticleDecorator.new(Article.first)`
6. Output the instance methods in your view templates
  ex: `@article_decorator.created_at`

## Watch the RailsCast

<NAME> has put together an excellent RailsCast on Draper based on the 0.8.0 release:

[![RailsCast #286](https://img.skitch.com/20111021-dgxmqntq22d37fthky6pttk59n.jpg "RailsCast #286 - Draper")](http://railscasts.com/episodes/286-draper)<commit_msg>Link build status and add dependency status to README<commit_after># Draper: View Models for Rails

[![TravisCI Build Status](https://secure.travis-ci.org/jcasimir/draper.png)](http://travis-ci.org/jcasimir/draper)
[![Gemnasium Build Status](https://gemnasium.com/jcasimir/draper.png)](https://gemnasium.com/jcasimir/draper)

## Quick Start

1. Add `gem 'draper'` to your `Gemfile` and `bundle`
2. Run `rails g draper:decorator YourModel`
3. Edit `app/decorators/[your_model]_decorator.rb` using:
  1. `h` to proxy to Rails/application helpers like `h.current_user`
  2. `[your_model]` to access the wrapped object like `article.created_at`
4. Put common decorations in `app/decorators/application.rb`  
5. Wrap models in your controller with the decorator using:
  1. `.find` automatic lookup & wrap
    ex: `ArticleDecorator.find(1)`
  2. `.decorate` method with single object or collection, 
    ex: `ArticleDecorator.decorate(Article.all)`
  3. `.new` method with single object
    ex: `ArticleDecorator.new(Article.first)`
6. Output the instance methods in your view templates
  ex: `@article_decorator.created_at`

## Watch the RailsCast

<NAME> has put together an excellent RailsCast on Draper based on the 0.8.0 release:

[![RailsCast #286](https://img.skitch.com/20111021-dgxmqntq22d37fthky6pttk59n.jpg "RailsCast #286 - Draper")](http://railscasts.com/episodes/286-draper)
{'fraction_non_alphanumeric': 0.12305900621118013, 'fraction_numerical': 0.030279503105590064, 'mean_word_length': 4.713968957871397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4283891', 'n_tokens_mistral': 962, 'n_tokens_neox': 884, 'n_words': 254}