开发者

undefined method `map' for

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜