Felix Felix - 10 months ago 69
Ruby Question

Ruby on Rails collection output in collection_select

I've got this code:

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

And got this error:

enter image description here

Its a normal active relation

enter image description here

Whats my mistake in this case?




You have to specify: object, method, collection, value_method, text_method, you probably forgot to set the object param.

Which would make this:

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

(replace :object with your object you want to save the channel to)