如何访问参数值中表单中的隐藏字段,但它表示意外的行结束

How to access a hidden field in form in the params value but it says unexpected line end

我有一个隐藏字段,我想允许我的提案控制器使用。

当我提交表格时它说

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])