Permalink
Browse files

Added an example.

  • Loading branch information...
1 parent eeffbb6 commit b67c34a32edcaa003340c8cf86dbeaf4e2943d53 @postmodern committed Nov 6, 2010
Showing with 23 additions and 0 deletions.
  1. +23 −0 README.md
View
23 README.md
@@ -10,6 +10,29 @@ A DataMapper plugin for adding counter-cache properties to related models.
## Example
+Adds counter properties to Post and User for the number of comments:
+
+ require 'dm-core'
+
+ class Comment
+
+ include DataMapper::Resource
+
+ is :counter_cacheable
+
+ property :id, Serial
+
+ property :body, Text
+
+ belongs_to :post
+
+ belongs_to :user
+
+ counter_cacheable :post
+ counter_cacheable :user, :counter_property => :post_comments_counter
+
+ end
+
## Requirements
* [dm-core](http://github.com/datamapper/dm-core/) ~> 1.0.0

0 comments on commit b67c34a

Please sign in to comment.