Skip to content

Instantly share code, notes, and snippets.

@SamSaffron
Created August 5, 2009 03:37
Show Gist options
  • Save SamSaffron/162489 to your computer and use it in GitHub Desktop.
Save SamSaffron/162489 to your computer and use it in GitHub Desktop.
# ok
class List
named_scope :without_address, lambda { |address_id| { :joins => :address_list_memberships, :conditions => ['address_list_memberships.address_id <> ?', address_id]}}
end
# ugly
class List
def self.without_address_lookup(address_id)
{
:joins => :address_list_memberships,
:conditions => ['address_list_memberships.address_id <> ?', address_id]}
}
end
named_scope :without_address, :without_address_lookup.to_proc
end
#pretty
class List
named_scope(:without_address, lambda do |address_id|
{
:joins => :address_list_memberships,
:conditions => ['address_list_memberships.address_id <> ?', address_id]}
}
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment