Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j-mcnally/3840f4438600a1f0eb96 to your computer and use it in GitHub Desktop.
Save j-mcnally/3840f4438600a1f0eb96 to your computer and use it in GitHub Desktop.
def find_by_hstore(hstore_hash, *args)
query = hstore_hash.collect{|k,v| "#{k} @> #{v}" }
if args.length > 0
find_by(*args).where(query)
else
where(query)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment