1

Possible Duplicate:
Enums in Ruby

How do you declare something like

public enum fruit {
    mango ("mango", 1),
    banana ("banana", 2),
    apple ("apple", 3)

    private fruit(String name, int index) {
        ....
    }
}

I would like to show the strings in the user interface, but would like to store the integers in the database.

Community
  • 1
  • 1
user339108
  • 12,613
  • 33
  • 81
  • 112
  • 3
    Have you looked here? http://stackoverflow.com/questions/75759/enums-in-ruby. – Daniel Le Aug 01 '11 at 10:55
  • When you are using enums with database you basically separating your data to two sources. I think it's much better to introduce another db table to store these values. – Yossi Aug 01 '11 at 11:02

0 Answers0