collection_select reseting selection whenever page refreshes

I have a collection_select dialog that I have for selecting Users on a page. I am wanting the selection to remember and display the last selected user from the database. Every time I refresh the page it is going back to its default value even though the data has changed. Is there a way to tell it to take the data that appears in the database and not reset the selection tag like it a new value.

Here is my code that I'm using. <% @users = User.list_all_testers %> <%= collection_select(:machine, :user_id, @users, :id, :fullname, options = {:include_blank=>true}, html_options = {:onChange => remote_function(:update => "ajaxmessage", :url => {:action => 'update_machine_user',             :controller => 'manage_machines',:id=>machine.id},:with=>"'users_id='+this.value")}) %>

Thanks William

http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M001753

I assume you have the Ajax and the update parts right. It is a question of populating the right value into @machine.

Mukund wrote:

ActionView::Helpers::FormOptionsHelper

I assume you have the Ajax and the update parts right. It is a question of populating the right value into @machine.

This is NOT working. See http://rails.lighthouseapp.com/projects/8994/tickets/1138-collection_select-doesnt-select-current-choice for details. Id is a FixNum value while the selected value is transfered as a String value.

So value and selected can never be the same in option_value_selected? If value is FixNum!