I trying to make drop-down list in form from my database data. I have table with wastes, and boolean is it toxic or not.
I tried to get this with this code:
<%= collection_select(:waste, :code, Waste.find_by_istoxic(true), :id, :code) %>
but I got error "undefined method `map' for #
With this it's works:
<%= collection_select(:waste, :code, Waste.all, :id, :code) %>
but I need some filtering.
I tried to make some like this but with no success:
<%= collection_select(:waste, :code, @toxicwastes, :id, :code) %>
and in controller:
@toxicwastes = Waste.find_by_istoxic(true)
开发者_Go百科
Any solution for this?
find_by_*
returns a single record, you want to use find_all_by_*
instead.
精彩评论