2016-07-27 128 views
1

集输出我有这样的代码:Ruby on Rails的在collection_select

<%= collection_select :channel, @channelList, :id, :channelname, {prompt: (t "channel.add.prompt")}, class: "form-control"%> 

而得到这个错误:

enter image description here

其正常活动的关系

enter image description here

这是什么我的错误?

感谢

+0

''@channelList它包含的? –

+0

@RajarshiDas看他最后的截图。 – siegy22

回答

1

http://edgeapi.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select

您必须指定:object, method, collection, value_method, text_method,你可能忘了设置object PARAM。

这将使这样的:

<%= collection_select :object, :channel, @channelList, :id, :channelname, {prompt: (t "channel.add.prompt")}, class: "form-control"%> 

(更换:object与你的对象,你要的通道保存)

+0

只是想打印出那些在选择,后来我想做一些jQuery的魔术;) – Felix

+0

工作正常,谢谢 – Felix

+0

好吧,没问题:) – siegy22