Carla Dessi
Carla Dessi

Reputation: 9666

Rails dropdown box from separate table

I currently have this as my dropdown:

<%= f.select :supplier, options_for_select(@supplier) %>

in my controller I have:

@software = Software.new
@supplier = Supplier.all

the form is for new software, the drop down should pull the suppliers from the supplier table which is completely unrelated to any other table. i then want the supplier field in the software form to be filled with one of the entries in the supplier table. at the moment my code just comes up with something like:

#<Supplier:0x000052e5c89>

Upvotes: 1

Views: 173

Answers (1)

Amar
Amar

Reputation: 6942

Try:

<%= f.collection_select :supplier, @supplier,:id,:name %>

Upvotes: 1

Related Questions