Skip to content

Instantly share code, notes, and snippets.

@willrjmarshall
Created February 22, 2012 00:21
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 willrjmarshall/1880133 to your computer and use it in GitHub Desktop.
Save willrjmarshall/1880133 to your computer and use it in GitHub Desktop.
def create_scopes(klass, attribute_name)
klass.enumeration.keys.each do |option|
if respond_to? :scope
scope option, where(attribute_name => klass.enumeration[option].first)
end
end
end
@bartimaeus
Copy link

Try:

scope option, lambda { where(attribute_name => klass.enumeration[option].first) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment