Dropdown selected value not reflecting in edit view

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.

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