Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (24 sloc) 929 Bytes
!!! PLEASE DO NOT USE RELATIONAL_SCOPE !!!
__________________________________________
i have not updated relational_scope since i created it.
If you are looking for something similar try searchlogic:
http://github.com/binarylogic/searchlogic
RelationalScope
===============
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
=======
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