Created
April 17, 2010 02:26
-
-
Save lucasmazza/369198 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Some fun with EnumerateIt | |
| class LocationType < EnumerateIt::Base | |
| associate_values(:House => 1, :Apartment => 2, :Island => 3) | |
| end | |
| class Location < ActiveRecord::Base | |
| has_enumeration_for :location_type | |
| LocationType.enumeration.values.each do |key, value| | |
| scope value.to_s.downcase.pluralize, where(:location_type => key) | |
| end | |
| end | |
| Location.houses | |
| # [#<Location... ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment