我遇到以下問題,我試圖用Google解決它,但沒有給出任何明顯的結果。列入白名單的參數不會出現在強參數中
我有形式更新模式,我一直在試圖新的參數添加到強的參數(model_params),它好像他們是不包括這些參數,可以事件雖然他們的值出現在常規PARAMS(使用byebug檢查出來)
def model_params
params.require(:model).permit(
:id, # new param
:hidden_field_param, # also new one
# Long list of parameters omitted
nested_model_attributes: [:id, :file, :_destroy])
end
PARAMS
<ActionController::Parameters { All parameters including new and old ones } permitted: false>
個
model_params
<ActionController::Parameters { Only old ones } permitted: true>
謝謝。
UPD
_form.html.erb(部分)
<%= form_for @model, :remote => true, :authenticity_token => true, :html => { multipart: true } do |f| %>
<!-- All other fields omitted, they are working correctly -->
<div class="row">
<div class="col-xs-12">
<%= hidden_field_tag :hidden_field_param, 'Here is string value' %>
<% count = 0 %>
<%= f.fields_for :nested_model, method: :post, class: "" do |ff| %>
<%= ff.file_field :file, multiple: true, id: 'pictures_' + (count=count+1).to_s, class: "image_item" %>
<% end %>
</div>
</div>
<p>
<%= f.submit 'Done', class: 'btn btn-primary' %>
</p>
<% end %>
你能發佈你的視圖文件嗎? –
當然,這裏是 –