Hi All,
controller:
def html
@tag1=[“Arun”,“Babu”,Chitra"]
end
html.html.erb :
<%= select_tag
“@tag1”,"#{@tag1[0]}#{@tag1[1]}
"%>
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
On Sat, Jul 26, 2008 at 3:03 AM, Raveendran J.
[email protected] wrote:
@tag.each do |value|
value=“”+value+“”
@collection << value
end
end
View:
<%= select_tag “@tag12”, @collection.to_s %>
you can try
<%= select_tag @tag12, options_for_select( @tag )
–
Gabriel L. [email protected]
Raveendran J. 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.
–
Phlip
Gabriel L. wrote:
you can try
<%= select_tag @tag12, options_for_select( @tag )
–
Gabriel L. [email protected]
Hi Laskar,
Thanks a lot for ur quick and beautiful code help.
Regards,
P.Raveendran