I’d like to generate a select form field, where a user can select one entry of another model. Currently I do it this way:
<%= f.select :wg, Warengruppe.all %>
and in my Warengruppe model I defined the to_s method this way:
def to_s
return self.titel
end
So I get an array of strings. But now I want to store just the id of the Warengruppe entry, so I need an array of [[id,title],[id,title]....]. Well I can write a method, that generates the array, but isn’t there a more rails way to do that?
What you’re looking for is;