중첩 된 특성을 데이터베이스에 입력하려고했지만 작동하도록 관리 할 수 없습니다.중첩 된 특성을 찾을 수 없거나 허용되지 않음
def domain_register_whois_contact_parameters
params.require(:domain).permit(whois_contacts_attributes: [:id, :first_name, :last_name, :street, :number, :postal_code, :city, :phone_number, :email_address, :company_type_id, :company_kvk, :company_name, :country_id])
end
이 입력 PARAMS :이 같은
{"utf8"=>"✓", "authenticity_token"=>"P4WTxAHKLgeRUQq60JvD/uMjo0s2BdMtqlBr1B6Z2hQ=", "domain"=>{"domain_name"=>"test.com", "whois_contacts_attributes"=>{"0"=>{"first_name"=>"Edward", "last_name"=>"Doe", "street"=>"Broadway", "number"=>"1", "postal_code"=>"1234AB", "city"=>"Amsterdam", "country_id"=>"205", "phone_number"=>"316123465", "email_address"=>"[email protected]", "company_name"=>"", "company_kvk"=>"", "company_type_id"=>""}}, "nameserver_first"=>"ns1.dns.com", "nameserver_second"=>"ns2.dns.com"}, "commit"=>"Register domain"}
내가지고있어 오류 : param not found: whois_contacts_attributes
은 많이 봤나요
나는이 매개 변수가 예제가 있지만 작동하지 않습니다. 내 모델에서나는이 :
accepts_nested_attributes_for :whois_contacts
그리고 내보기 :
나는 다르게 할 것 3 가지가 있습니다<%= f.simple_fields_for :whois_contacts, @domain.whois_contacts.new do |wc| %>
<%= wc.input :first_name, input_html: { placeholder: "John" } %>
<%= wc.input :last_name, input_html: { placeholder: "Doe" } %>
<%= wc.input :street, input_html: { placeholder: "Main street" } %>
<%= wc.input :number, input_html: { placeholder: "1" } %>
<%= wc.input :postal_code, input_html: { placeholder: "1234AB" } %>
<%= wc.input :city, input_html: { placeholder: "Amsterdam" } %>
<div class="form-group select required domain_country_country_name">
<label class="select required form-label" for="domain_country_country_name">
<abbr title="required">*</abbr> Country
</label>
<div class="controls">
<%= wc.collection_select :country_id, Country.all, :id, :full_name, {}, {:class=>'select required form-control'} %>
</div>
</div>
<%= wc.input :phone_number, input_html: { placeholder: "0612345678" } %>
<%= wc.input :email_address, input_html: { placeholder: "[email protected]" } %>
<h3>Company information</h3>
<%= wc.input :company_name, hint: 'If you have a company, please enter the company name.', input_html: { placeholder: "Doe Inc." } %>
<%= wc.input :company_kvk, hint: 'Enter Chamber of Commerce (Kvk) number', input_html: { placeholder: "12345678" } %>
<div class="form-group select required domain_company_company_name">
<label class="select required form-label" for="domain_company_companyname">
<abbr title="required">*</abbr> Company
</label>
<div class="controls">
<%= wc.collection_select :company_type_id, CompanyType.all, :id, :full_name, {}, {:class=>'select required form-control'} %>
</div>
</div>
<% end %>
나는거야을 형태를 조정 사지에 나가서 params를 비난하는 것. Rails 4가 옮겨온 params의 화이트리스트를 정말 좋아하지만 화이트리스트에 사용자 친화적 인 인터페이스를 만들 수있었습니다. 나는 그것에 대해 파헤 치고, 그것에 대해 질문에 대답했으며, 나는 그것이 어떻게 작동하는지 아직도 이해하지 못하고있다. 내가 여기 준 대답을 한번보세요 : http://stackoverflow.com/questions/19189602/unpermitted-parameters-for-dynamic-forms-in-rails-4/19194274#19194274 당신의 문제는 반대 생각합니다. 'permit' 문에 배열을 코딩하고 있지만, 매개 변수에 중첩 해시가 있습니다. – Beartech
"whois_contacts_attributes"=> { "0"=> { "first_name"=> "Edward",''whois_contacts_attributes => { "first_name"=> "에드워드 ", ...." 이것은 내 두 번째 약점 인 simple_fields_for API를 지적합니다. 그것은 나를위한 약간의 블랙 박스입니다. 그래서 나는 그것을 빠져 나가기 원하는 매개 변수를 얻는 방법을 정말로 이해하지 못합니다. 폼에서 반환하는 매개 변수를 출력하는 폼에서 컨트롤러 동작을 수행 할 수 있습니까? 그게 내가 과거에 이들 매개 변수 신비의 일부를 사냥 한 방법이다. – Beartech