Skip to content

Instantly share code, notes, and snippets.

@liangzan
Created September 24, 2010 07:38
Show Gist options
  • Save liangzan/594999 to your computer and use it in GitHub Desktop.
Save liangzan/594999 to your computer and use it in GitHub Desktop.
# lib/searchlogic/named_scopes/conditions.rb
def method_missing(name, *args, &block)
if details = condition_details(name)
create_condition(details[:column], details[:condition], args)
send(name, *args)
elsif boolean_condition?(name)
column = name.to_s.gsub(/^not_/, "")
named_scope name, :conditions => {column => (name.to_s =~ /^not_/).nil?}
send(name)
else
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment