# Collection\_select - adding an option for "all"

**URL:** <https://www.ruby-forum.com/t/collection-select-adding-an-option-for-all/85681>\
**Category:** Rails\
**Created:** [February 15, 2007, 3:01pm UTC](https://www.ruby-forum.com/t/collection-select-adding-an-option-for-all/85681 "2007-02-15T15:01:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kathys39](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@kathys39](https://www.ruby-forum.com/u/kathys39)\
**Post date:** [February 15, 2007, 3:01pm UTC](https://www.ruby-forum.com/t/collection-select-adding-an-option-for-all/85681/1 "2007-02-15T15:01:31Z")

</div>

I’m using collection\_select to populate a drop-down menu with items from  
a database. That part is working fine. I’d like to add an option for  
“all” in the drop-down menu in case the user wants to see data for all  
the stores - how can I do this? Thanks

---

<div class="post-metadata">

**Author:** ![kathys39](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@kathys39](https://www.ruby-forum.com/u/kathys39)\
**Post date:** [February 15, 2007, 5:01pm UTC](https://www.ruby-forum.com/t/collection-select-adding-an-option-for-all/85681/2 "2007-02-15T17:01:32Z")

</div>

you can pass :include\_blank =\> true as an option which adds a blank  
option as the first option, but i don’t think there is a way to set  
the text or value of the blank option.

collection\_select(:model, :id, @models, “id”, “name”, :include\_blank =\>  
true)

---

<div class="post-metadata">

**Author:** ![kathys39](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@kathys39](https://www.ruby-forum.com/u/kathys39)\
**Post date:** [February 15, 2007, 5:09pm UTC](https://www.ruby-forum.com/t/collection-select-adding-an-option-for-all/85681/3 "2007-02-15T17:09:33Z")

</div>

after looking at the source, there is a way…

use the :prompt =\> “All” option in place of the :include\_blank option  
and you will get an initial option with the text set to what you pass  
and the value will be empty

collection\_select(:model, :id, @models, “id”, “name”, :prompt =\> “All”)

then just check for a blank value being submitted.

---

<div class="post-metadata">

**Author:** ![kathys39](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/ebca7d/32.png) [@kathys39](https://www.ruby-forum.com/u/kathys39)\
**Post date:** [February 16, 2007, 1:23pm UTC](https://www.ruby-forum.com/t/collection-select-adding-an-option-for-all/85681/4 "2007-02-16T13:23:56Z")

</div>

Works like a charm - thank you!
