Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Commit

Permalink
add short description and example to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zacheryph committed Feb 20, 2009
1 parent 1abfdc0 commit 3d0ef1e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README
@@ -1,13 +1,31 @@
RelationalScope
===============

Introduction goes here.
This plugin makes it possible to filter a specific model using the
named_scope's of one of its relations. This prevents making duplicate
named_scopes in multiple models.


Example
=======

Example goes here.
class Post < ActiveRecord::Base
belongs_to :author

has_relational_scope :author, :prefix => 'a'
end

class User < ActiveRecord::Base
named_scope :admins, :conditions => {:admin => true}
end

In your Controller you can go:

@posts = Post.a_admins

This will fetch all and only posts where the author is an admin.

Without the :prefix option this would be called as Post.author_admins


Copyright (c) 2009 Zachery Hostens, released under the MIT license

0 comments on commit 3d0ef1e

Please sign in to comment.