Created
August 19, 2011 21:19
-
-
Save emschwar/1158032 to your computer and use it in GitHub Desktop.
Named scopes that re-use other named scopes via proxy_options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parent < ActiveRecord::Base | |
named_scope :ready, :conditions => { :ready_at => true } | |
has_many :children | |
end | |
class Child < ActiveRecord::Base | |
belongs_to :parent | |
named_scope :ready, lambda { | |
:joins => :parent, | |
:conditions => Parent.ready.proxy_options[:conditions] } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment