Could you please provide a concrete example of what you need from enum feature? How would you like to use?
Rafael Mendonça França http://twitter.com/rafaelfranca https://github.com/rafaelfranca On Mon, Apr 14, 2014 at 9:53 PM, Sadjow Leão <sad...@gmail.com> wrote: > Yeap, T.J. > > But, actually enums are not only for persisted AR objects, we can find > enumerations where we can have a pre-defined list of values. > > A validation doesn't matter here. I'need the same enum API for a model. > > Without this behaviour in ActiveModel, we will end up making a similar > behaviour of enums to accomplish this need. > > > > > On Mon, Apr 14, 2014 at 6:37 PM, T.J. Schuck <t...@getharvest.com> wrote: > >> > Why not put Enum into ActiveModel? We may need some enumeration into >> another model without ActiveRecord, a example: something like a mail object >> form with a enumeration for subject… >> >> If the object isn’t persisted to the DB, it doesn’t seem like you’d need >> to use AR::Enum — the primary benefit is that it maps the options to >> integers in the DB column. For a non-persisted model, you can just use a >> regular attribute with an inclusion validation like Rafael mentioned. >> >> > By what you described I believe you can reach with >> validates_inclusion_of and a hash. >> >> Note that AR::Enum doesn’t play nicely with `inclusion` validations — see >> https://github.com/rails/rails/issues/13971 — so this only applies to >> the provided workaround for a non-persisted object. >> >> >> >> On Mon, Apr 14, 2014 at 4:29 PM, Rafael Mendonça França < >> rafaelmfra...@gmail.com> wrote: >> >>> Hi, >>> >>> Could you explain a bit more about the use case you are thinking for >>> enum feature on Active Model? >>> >>> By what you described I believe you can reach with >>> validates_inclusion_of and a hash. An example of the controller and >>> view would help. >>> >>> Also, could you also explain what is the use case for i18n for enum >>> values? >>> >>> Rafael Mendonça França >>> http://twitter.com/rafaelfranca >>> https://github.com/rafaelfranca >>> >>> >>> On Mon, Apr 14, 2014 at 4:25 PM, Sadjow Leão <sad...@gmail.com> wrote: >>> >>>> Hi folks, >>>> >>>> I'm thinking about a Pull Request for Rails. But, I want to validate >>>> with you. >>>> >>>> Why not put Enum into ActiveModel? We may need some enumeration into >>>> another model without ActiveRecord, a example: something like a mail object >>>> form with a enumeration for subject... and other situations. >>>> >>>> And a second Pull Request is: >>>> >>>> i18n for enum values. We need that. >>>> >>>> What do you think about? >>>> >>>> Thanks, >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Core" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to rubyonrails-core+unsubscr...@googlegroups.com. >>>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>>> Visit this group at http://groups.google.com/group/rubyonrails-core. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to rubyonrails-core+unsubscr...@googlegroups.com. >>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>> Visit this group at http://groups.google.com/group/rubyonrails-core. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-core+unsubscr...@googlegroups.com. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Sadjow Medeiros Leão > Software Engineer > http://github.com/sadjow > http://www.linkedin.com/pub/sadjow-le%C3%A3o/16/1/966 > <http://www.rits.com.br> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.