Tom Milewski
2009-Apr-26 02:40 UTC
Concatenating to an array constant for options_for_select
Hello, I have the following code: <%= select_tag :role, options_for_select(Project::COMPANY_ROLES.concat ([''Other...'']), @relationship.role), :class => ''selectInput hasOtherValue'' %> For some reason it concatenates "Other..." to COMPANY_ROLES but saves this past the view that was loaded. 1st Run = 1 option of "Other..." 2nd Run = 2 options of "Other..." 3rd Run = 3 options of "Other..." I simply want it to concatenate during run-time and not save state. Any ideas? Thanks!
Tom Milewski
2009-Apr-26 15:57 UTC
Re: Concatenating to an array constant for options_for_select
This does the trick: <%= select_tag :role, options_for_select(Project::COMPANY_ROLES + [''Other...''], @relationship.role), :class => ''selectInput hasOtherValue'' %> On Apr 25, 10:40 pm, Tom Milewski <tmilew...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I have the following code: > > <%= select_tag :role, options_for_select(Project::COMPANY_ROLES.concat > ([''Other...'']), @relationship.role), :class => ''selectInput > hasOtherValue'' %> > > For some reason it concatenates "Other..." to COMPANY_ROLES but saves > this past the view that was loaded. > > 1st Run = 1 option of "Other..." > 2nd Run = 2 options of "Other..." > 3rd Run = 3 options of "Other..." > > I simply want it to concatenate during run-time and not save state. > > Any ideas? > > Thanks!