DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Enums Emulation In Ruby
Type = [V1 = 'v1', V2 = 'v2']
class EntryForm
include ActiveModel::Validation
Remind = [Periodically = 'periodically', Once = 'once', Never = 'never']
validate_inclusion_of :remind, :in => Remind
before_save {
if @remind == Periodically
self.schedule_yaml = create_schedule(...).to_yaml
...
}
...
end
_form.html.haml:
... f.select :remind, EntryForm::Remind ...





