views:

22

answers:

2

I am making a select box, and I'm using a collection in it. But at the top of all the selections I want to add something that otherwise wouldn't be in that collection.

Here is my select box :

  = select (@organization, "tabs", @organization.tabs.collect { |t| [t.title, t.id] }, {}, {:class => "text_tab_link"} )

And I would like to add the words About and Edit as an additional selection at the top of the collection.

Anyone know how to pimp a select box?

+3  A: 

Something like this perhaps? Choose the special ids as appropriate.

@custom = [ ["About", -1], ["Edit", -2] ]

= select (@organization, "tabs", (@custom + @organization.tabs.collect { |t| [t.title, t.id] }), {}, {:class => "text_tab_link"})
bjg
@bjg , thanks so much friend. I really appreciate it.
Trip
+1  A: 

Another variant

select (@organization, "tabs", options_for_select(["Partial", "Exact"])+
  options_from_collection_for_select(@organization.tabs, "title", "id"), {}, {:class => "text_tab_link"} )
Bohdan Pohorilets