Forum: Ruby on Rails Concatenating to an array constant for options_for_select

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tom M. (Guest)
on 2009-04-26 06:41
(Received via mailing list)
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 M. (Guest)
on 2009-04-26 19:58
(Received via mailing list)
This does the trick:

<%= select_tag :role, options_for_select(Project::COMPANY_ROLES +
['Other...'], @relationship.role), :class => 'selectInput
hasOtherValue' %>
This topic is locked and can not be replied to.