I’m very new to ROR, and I’m having a problem making the elements in my drop down menu be unique. The menu allows the user to select a Company from a database. At the moment, the menu is listing every Company in the database, because the database holds the same company many times, and I only want that one company to show up once.
<%= f.label :company_name %><br />
<%= f.select( :company_name, Company.all.map {|c| [c.company_name]} ) %>
I know this should be quite simple to fix, but I can’t seem to find an answer. Hopefully someone can help.
Thanks in advance.
You could use:
But be careful with the id’s of the companies and how you’re going to use them.
Hope it helps!