There is no golden hammer.
For some fix things I use the method in helper and for some dynamic
things usually data is stored in Db somewhere and I think that I have
one using data from yaml file.
So use as you see fit.
dima
On Feb 14, 11:44 am, "Morten"
<use...-Mr43XxmkdKzQT0dZR+AlfA@public.gmane.org>
wrote:> When having a select box like:
>
> Select profession:
> * Unemployed
> * Hooligan
> * Canoo
>
> I''ve on some occasions used a "type" class:
>
> class ProfessionType < BaseType
> @types = {}
> @types[0] = ProfessionValue.new(''Unemployed'')
> @types[1] = ProfessionValue.new(''Hooligan'')
> @types[2] = ProfessionValue.new(''Canoo'')
> end
>
> Where BaseType facilitates some convenience methods (allowing for eg.
> ProfessionType.HOOLIGAN which returns 1, or returning an array
> appropriate for generating the options for a select).
>
> This approach works fine, but doesn''t feel quite right. An
alternative
> approach could be to just hard code the select box and save the string
> values directly in the DB. Or one could make a "selectables"
table in
> the DB and model it like:
>
> Selectable < AR::Base
> #... convenience methods here ...
> def options_for_select
> #...
> end
> end
>
> ProfessionSelectable < Selectable
> end
>
> But this is probably overdoing it, especially if the options are
> fixed.
>
> I''m curious to know how others treat their options for selects -
so
> what do you do?
>
> Thanks.
>
> Morten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---