Dropdown-Select for Database Table

I just want to have a dropdown menu in which all the rows of the table will be selected. How do I achieve this? Say I have a Student model, and I want the name property to be displayed in the selection.

Thanks in advance.

+5
source share
2 answers

Use select , for example:

select(:model, :attribute, Student.all.collect {|p| [ p.name, p.id ] })
+6
source

Here is some information on using collection selection ...

http://www.fmhcc.com.au/ruby/rails/using-collection_select-in-rails/

+2
source

All Articles