How to do enumerations in Rails 3?
In Rails 2 I know of a few plugins 开发者_如何学Cfor enumerations such as acts_as_enumeration and enumerate_by but they don't seem to be maintained or updated for Rails 3. Preferably, the solution would store the enum in memory rather than a database for performance reasons but really any method would be useful since it can always be cached.
I did find enumerated_attribute that claims to work with Rails 3 but quite honestly I don't like the API and was hoping for another good solution.
(Sorry for only linking to the one plugin but it won't let me post more than one link until I get a higher reputation)
I am currently using lwe's simple_enum which seems to be actively developed and stores values on memory or if you prefer on a table.
If you're using DataMapper as your ORM have a look at dm-types which includes an Enum type.
There is this gem, enumerate_it, it has good documentation and very well done!
精彩评论