Problem with select_tag

hi friends,

i have used select_tag for country selection.
in this select_tag i want to make one of the option by default selected.
how to do it?
plz somebody help me.

code:

.rhtml

<%= select_tag “country”,
options_from_collection_for_select(@country,“id”,“name”,@selected) %>

controller

@country = City.find_by_sql(“select * from countries”)

Did you ever figure this one out? I’ve been struggling with the same
question. Its easy with the model forms (form_for, form.select) but
not for non-model forms that I can see.

Any help? Anyone?

  • Brian

trupti wrote:

.rhtml

<%= select_tag “country”,
options_from_collection_for_select(@country,“id”,“name”,@selected) %>

please modify “@selected” to “[email protected])”.

yang jindong wrote:

trupti wrote:

.rhtml

<%= select_tag “country”,
options_from_collection_for_select(@country,“id”,“name”,@selected) %>

please modify “@selected” to “[email protected])”.

i’m sorry.there’s a mistake.please delete the “)”.