select_tag help

Hi All,

controller:

def html   @tag1=["Arun","Babu",Chitra"] end

html.html.erb :

<%= select_tag "@tag1","<option>#{@tag1[0]}</option><option>#{@tag1[1]}</option> "%><br/>

It was working fine. But my question is any other simple ways are available. Because i have array in controller, but using individually in view..

Awaiting your reply

Thanks P.Raveendran

Hi All,

i herewith written my final working code.....

controller:

def htmlhelp     @tag=["a","b","c","d"]     @collection=

    @tag.each do |value|       value="<option>"+value+"</option>"       @collection << value       end end

View:

<%= select_tag "@tag12", @collection.to_s %>

Any other short ways...?

Regards, P.Raveendran http:raveendra.wordpress.com

you can try <%= select_tag @tag12, options_for_select( @tag )

Gabriel Laskar wrote:

you can try <%= select_tag @tag12, options_for_select( @tag )

-- Gabriel Laskar <bibi.skuk@gmail.com>

Hi Laskar,

Thanks a lot for ur quick and beautiful code help.

Regards, P.Raveendran

Raveendran Jazzez wrote:

<%= select_tag @tag12, options_for_select( @tag )

Hi Laskar,

Thanks a lot for ur quick and beautiful code help.

Now try this one.

The @yo object has a list of ids from the a model called Mod.

We need this to make the ids sticky in the form:

form_for :yo do |f|

   f.collection_select(:ids, Mod.find(:all), :id, :name)

The problem is, even after we make all that pseudo-Rails into real Rails code, with all the right arguments, the ids are not sticky.

(Sticky means if you serve the page twice with the same @yo object, the same Mod items should still be selected.)

Any ideas? We had to go back to select_tag, and generally do for ourselves everything f.collection_select was supposed to do.