thing.is_organic = true
thing.toggle! :is_organic
thing.is_organic? # provided by AR if type is boolean
nonorganics = Thing.find_all_by_is_organic(false)
Suppose I miss the C++ metamacro trick. Suppose I have global constants:
YoDude = 2
WhatsUp = 3
Now I want a 2 to produce 'YoDude' as a string, and 3 to produce 'WhatsUp'. Preferrably without overloading 2 and 3, and without creating a new lookup table. (That would happen if we go over 10 or so constants and I return control to the OnsiteCustomer.)
How do I do an enumeration that can reflect its values as strings?
Hi, I would recommend using a Hash to achieve your goal. Also, I
would highly recommend getting a good understanding of the Ruby
language an its associated idoms.
You'll find this to be very helpful when you're working with the Rails
web development framework.