# Select/Option selected value

**URL:** <https://www.ruby-forum.com/t/select-option-selected-value/50360>\
**Category:** Rails\
**Created:** [December 15, 2005, 6:15pm UTC](https://www.ruby-forum.com/t/select-option-selected-value/50360 "2005-12-15T18:15:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jschairb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jschairb](https://www.ruby-forum.com/u/jschairb)\
**Post date:** [December 15, 2005, 6:15pm UTC](https://www.ruby-forum.com/t/select-option-selected-value/50360/1 "2005-12-15T18:15:54Z")

</div>

I’m trying to get a select box to populate with the current option for  
editing  
purposes. I can populate the box, but not with the currently selected  
value.  
I’ve read in the api where it says to do this:

```
  # Example with @post.person_id => 1:
  # select("post", "person_id", Person.find_all.collect {|p| [ 

```

p.name,  
p.id ] }, { :include\_blank =\> true })

and

```
  # By default, post.person_id is the selected option. Specify 

```

:selected =\>  
value to use a different selection  
# or :selected =\> nil to leave all options unselected

I have this in my view:

\<%= select(“impact”, “guide\_id”, Guide.find\_all.collect {|p| [p.acronym,  
p.id ]  
}, { :include\_blank =\> true} ) %\>

I know guide\_id variable is set because in the tag before it I can show:

\<%= impact.guide\_id %\>

I’ve even tried this, which just makes the box say “Please select” upon  
load:

\<%= select(“impact”, “guide\_id”, @guides, :id, :acronym, :selected =\>  
impact.guide\_id) %\>

I’m trying to do all this in a for loop. I’ve seen where there appears  
to be  
some changed made to ActionPack in regards to this feature, but it seems  
to be  
only if I want to set the selected value to something other than  
@variable.method.

[http://dev.rubyonrails.org/ticket/1125](http://dev.rubyonrails.org/ticket/1125)  
[http://dev.rubyonrails.org/ticket/2991](http://dev.rubyonrails.org/ticket/2991)

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![jschairb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jschairb](https://www.ruby-forum.com/u/jschairb)\
**Post date:** [December 15, 2005, 6:25pm UTC](https://www.ruby-forum.com/t/select-option-selected-value/50360/2 "2005-12-15T18:25:02Z")

</div>

I’m having similar issues, and posted right after you :)… Keep an eye  
on my thread, as I’ll be following yours 🙂

---

<div class="post-metadata">

**Author:** ![jschairb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e8cbc/32.png) [@jschairb](https://www.ruby-forum.com/u/jschairb)\
**Post date:** [December 15, 2005, 9:15pm UTC](https://www.ruby-forum.com/t/select-option-selected-value/50360/3 "2005-12-15T21:15:55Z")

</div>

Joe E. wrote:

> I’m having similar issues, and posted right after you :)… Keep an eye  
> on my thread, as I’ll be following yours 🙂

My issues apparently stemmed from Firefox not fully reloading the page…
