Skip to content

Instantly share code, notes, and snippets.

@emschwar
Created August 19, 2011 21:19
Show Gist options
  • Save emschwar/1158032 to your computer and use it in GitHub Desktop.
Save emschwar/1158032 to your computer and use it in GitHub Desktop.
Named scopes that re-use other named scopes via proxy_options
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