我有一个想允许我的提案控制者使用的隐藏字段。
[当我提交表格时说
unexpected line end for proposal_params
我在这里想念东西吗?
_ form.html.haml:
%fieldset.col-md-12 = form.label t('.select_tags'), { class: 'tags-label' }
= form.hidden_field :tags, { class: 'hidden_tags' }
控制器:
def proposal_params
params.require(:proposal).permit(:title, :description, :target_audience,
:details, :pitch, :difficulty, :track_id,
:main_tag_id, comments_attributes: %i[body proposal_id person_id],
speakers_attributes: %i[person_id id], :tags)
end
尽管我可以通过执行params[:proposal][:tags]
来访问该值。
在Ruby中,调用带有位置和关键字参数的方法时,必须将关键字参数放在最后:
def foo(*args, **kwargs); end
foo(1, 2, 3, bar: 'baz')
foo(bar: 'baz', 1, 2, 3) # syntax error
params.require(:proposal).permit(:title, :description, :target_audience,
:details, :pitch, :difficulty, :track_id,
:main_tag_id, :tags,
comments_attributes: %i[body proposal_id person_id],
speakers_attributes: %i[person_id id])