Keep collection_select as selected after "submit"

Dear All,

Anybody knows to keep the selected option as alive even after “submit” in collection_select.

Dear All,

Anybody knows to keep the selected option as alive even after “submit” in collection_select.

Hi,
I found the method. If I use like this I can keep as live.
<%= collection_select(@table, “gm”, @pop, “col1”, “col1”, :prompt => true, :selected => params[:gm]) %>

The bold marked content, I inserted to my script and the selected value remains.

I think it is not considered good practice to directly reference
params in the view, as that means that the view is directly dependent
on the way the controller action was called. It might be better in
the controller action to say
@selected_item = params[:gm]
and then in the view use :selected = @selected_item.
It amounts to the same thing but achieves better separation of the
different bits of code.

Colin