README.markdown in acts-as-joinable-0.0.1.5 vs README.markdown in acts-as-joinable-0.0.1.6
- old
+ new
@@ -49,6 +49,33 @@
t.timestamps
end
## Alternatives
-- [ActsAsRelationable](http://github.com/winton/acts_as_relationable)
+- [ActsAsRelationable](http://github.com/winton/acts_as_relationable)
+
+## Examples
+
+If you would like to define accessors that scope the relationship based on the `context` attribute of the `Relationship` model, you can do this:
+
+ class Post < ActiveRecord::Base
+ acts_as_joinable_on :assets, :scopes => [:featured, :thumb]
+ end
+
+ @post = Post.new
+ @post.featured_assets << Asset.first
+
+If you need more fine-grained control over each relationship scope, you can use a block:
+
+ class Post < ActiveRecord::Base
+ acts_as_joinable_on :assets do
+ has_one :featured_image, where(:...)
+ has_many :thumbnails
+ end
+ acts_as_joinable_on :tags
+ end
+
+ @post = Post.new
+ @post.featured_image = Image.first
+ @post.thumbnails = Image.all
+
+The goal of this is to make it so you never have to create migrations or new classes, or rewrite the same code over and over again. Instead, you can just define `scopes` for cherry-picking the habtm items you'd like.
\ No newline at end of file