Skip to content

Commit

Permalink
fixing generator names in README
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed May 9, 2012
1 parent b516bda commit 5549614
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Readme.markdown
Expand Up @@ -6,18 +6,19 @@
## 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:
2. When you generate a resource with `rails g resource YourModel`, you get a decorator automatically!
3. If YourModel exists, run `rails g decorator YourModel`
4. 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. Wrap models in your controller with the decorator using:
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)`
5. Output the instance methods in your view templates
6. Output the instance methods in your view templates
ex: `@article_decorator.created_at`

If you need common methods in your decorators, create an `app/decorators/application_decorator.rb`:
Expand Down

0 comments on commit 5549614

Please sign in to comment.