开发者

undefined method `map' for

开发者 https://www.devze.com 2023-02-12 09:42 出处:网络
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 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

精彩评论

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