# Dropdown selected value not reflecting in edit view

**URL:** <https://www.ruby-forum.com/t/dropdown-selected-value-not-reflecting-in-edit-view/144192>\
**Category:** Rails\
**Created:** [July 26, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/dropdown-selected-value-not-reflecting-in-edit-view/144192 "2008-07-26T14:00:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaily903](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shaily903](https://www.ruby-forum.com/u/shaily903)\
**Post date:** [July 26, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/dropdown-selected-value-not-reflecting-in-edit-view/144192/1 "2008-07-26T14:00:05Z")

</div>

hi

I am facing the following issue:

I have the following dropdown, in the new view  
select\_tag “experience[]”, options\_for\_select([[less\_than\_1\_year,  
[0,1]],[between\_1\_and\_3\_years, [1,3]],[between\_3\_and\_5\_years,  
[3,5]],[between\_5\_and\_7\_years,[5,7]], [between\_7\_and\_10\_years,[7,10]],  
[above\_10\_years,[10,50]]])

The selected value of the user is not getting reflected in the Edit view  
of the entry.  
I am using the Form\_partial.

Edit View:  
\<% form\_for(@defaultrate) do |f| %\>  
\<%= render :partial =\>“form”, :locals =\> { :f =\> f, :button =\>  
“Update” } %\>  
\<% end %\>

New view:  
\<% form\_for(@defaultrate) do |f| %\>  
\<%= render :partial =\>“form”, :locals =\> { :f =\> f, :button =\>  
“Create” } %\>  
\<% end %\>

Please let me know what changes has to be made in controller and view to  
reflect the selected value during Edit.

---

<div class="post-metadata">

**Author:** ![shaily903](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@shaily903](https://www.ruby-forum.com/u/shaily903)\
**Post date:** [July 26, 2008, 4:02pm UTC](https://www.ruby-forum.com/t/dropdown-selected-value-not-reflecting-in-edit-view/144192/2 "2008-07-26T16:02:29Z")

</div>

You must tell options\_for\_select which one has to be marked selected  
That’s the 2nd parameter.

options\_for\_select(container, selected = nil)

for example:  
options\_for\_select([“VISA”, “MasterCard”], “MasterCard”)

would set MasterCard as selected.

So you just store the returned params[:experience]  
somewhere and use that value when redisplaying the select
