这是我的代码片段,它完全按预期工作:
<%= f.select(:other_model_id,
options_from_collection_for_select(
OtherModel.all,
:id,
:full_name,
{ :selected => @this_model.other_model_id} )) %>
但由于某种原因,这不起作用:
<%= f.collection_select :this_model, :other_model_id,
OtherModel.all, :id, :full_name %>
我得到的错误是:
:full_name:Symbol 的未定义方法“合并”
有什么建议么?:full_name 与工作代码一起正常工作的事实让我相信我搞砸了简化的 collection_select 代码中的语法,并且问题不在其他地方。