Skip to content

Instantly share code, notes, and snippets.

@joerixaop
Forked from spint/lambda_in_named_scope.rb
Created December 13, 2010 14:16
Show Gist options
  • Save joerixaop/739020 to your computer and use it in GitHub Desktop.
Save joerixaop/739020 to your computer and use it in GitHub Desktop.
class LowCoverReport < ActiveRecord::Base
# The other solution would fail for an empty list of countries
# If you don't need it you also can leave out the class variable
country_query = lambda{|o| {:conditions => ["country_id IN (?)", o.countries]} }
named_scope :for_user, country_query
named_scope :for_session, country_query
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment