Select()


#1

I got for now this code html

Yes No display

I need to transfer this code to ruby
some like =>

<%= select(“property”, “location_id”,Location.find(:all, :conditions =>
"name != ‘’ ").collect {|p| [p.name, p.id]}, { :include_blank => false
}) %>

function above look for from database some data and put it into the drop
box fields
I need display only YES and NO and set them values 0 and 1

any ideas ?


#2

misiek wrote:

<%= select(“property”, “location_id”,Location.find(:all, :conditions
=> "name != ‘’ ").collect {|p| [p.name, p.id]}, { :include_blank =>
false }) %>

function above look for from database some data and put it into the
drop box fields
I need display only YES and NO and set them values 0 and 1

any ideas ?

Have you looked at erb
(http://ruby-doc.org/stdlib/libdoc/erb/rdoc/index.html) or the CGI
standard library
(http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html)?

Or do you mean parsing the HTML and making into that code?

-Justin


#3

Go to http://api.rubyonrails.com/ and click on the Method named
“collection_select”. It does just what you want.


#4

Why not use a check box? I always hated drop downs for binary state
variables.

_Kevin