Rails Params在params中丢失,但在request.body中存在

时间:2019-01-31 11:38:05

标签: ruby-on-rails ruby-on-rails-4 parameters jruby

我有一个带有表单的工作项目,但是在某些情况下,在表单提交期间,请求主体参数没有传递到控制器中的参数上

这是我将binding.pry作为before_action放在应用程序控制器中时看到的内容

[1] pry(#<App::Agent::V2::VerificationsController>)> request.url
=> "http://localhost:4567/app/agent/v2/verifications/sg_bug_bash/submit"
[2] pry(#<App::Agent::V2::VerificationsController>)> request.body.read
=> "utf8=%E2%9C%93&authenticity_token=2myJbSTptXGEGn8a14T3zj7cgMSc%2F8zsLI27%2BirR6ZplQotMkTDfGWgKes3k9OSIfnL5wKyFvazn7tvNS9zuHQ%3D%3D&obs_application%5Boperation_name%5D=sg_bug_bash&obs_application%5Bapplication_id%5D=1&commit=Submit%2FDone&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_bank_statement%5D%5Bid%5D=e4c987fb-a875-420e-81db-45a8482d36eb&resubmit_status%5BRotate%5D=0&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_bank_statement%5D%5Brejection_reasons%5D%5B%5D=&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_bank_statement%5D%5Brejection_reasons%5D%5Baccount_number%5D=+not+valid+&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_bank_statement%5D%5Brejection_reasons%5D%5Bbank_code%5D=&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_lta_vehicle_log_card%5D%5Bid%5D=4d6fd458-2a46-4f8b-bf9e-0f7b26ea16f2&resubmit_status%5BRotate%5D=0&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_lta_vehicle_log_card%5D%5Brejection_reasons%5D%5B%5D=&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_lta_vehicle_log_card%5D%5Brejection_reasons%5D%5Bvehicle_plate_number%5D=&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_lta_vehicle_log_card%5D%5Brejection_reasons%5D%5BvehicleBrand%5D=+not+valid+&obs_application%5Bpanels%5D%5Bdocuments%5D%5Bsg_lta_vehicle_log_card%5D%5Brejection_reasons%5D%5BvehicleType%5D="
[3] pry(#<App::Agent::V2::VerificationsController>)> params
=> {"controller"=>"app/agent/v2/verifications", "action"=>"submit", "id"=>"sg_bug_bash"}

这是动态生成的表单,因此HTML如下所示:

<form id="verification-form" class="edit_obs_application" action="/app/agent/v2/verifications/sg_bug_bash/submit" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="authenticity_token" value="j1rCDid+EAiODQijn+TNTml/MTwikobF2Tg63ssZ+EtAAH/ebLimZd8C5D1oXhLYHr9EohRvmnSfnmE7ikrSdw==">
                    <input value="sg_bug_bash" type="hidden" name="obs_application[operation_name]" id="obs_application_operation_name">
                    <input value="220" type="hidden" name="obs_application[application_id]" id="obs_application_application_id">




<div class="panel">
  <div class="panel-heading">
    <div class="label">Surat Tanda Nomor Kendaraan: STNK</div>
  </div>
  <div class="panel-body">
    <div class="container">


              <input value="4d6fd458-2a46-4f8b-bf9e-0f7b26ea16f2" type="hidden" name="obs_application[panels][documents][sg_lta_vehicle_log_card][id]" id="obs_application_panels_documents_sg_lta_vehicle_log_card_id">
                  <div class="row verification-buttons row-bordered mandatory-action-true border-blank-false">
  <div class="col-md-6">
    <div class="label"> Vehicle type*: </div>

    <div class="verification-value">166</div>

  </div>
  <div class="col-md-6 mandatory-action-true}">
            <div class="row component-validation" id="vehicleType">
  <input type="hidden" value="vehicleType" class="component-field">
  <div class="row verification-buttons display-block">
    <div class="col-md-8 invalid ">
      <div id="tableDiv" class="dropdown">
        <button id="tableButton" class="btn btn-invalid dropdown-toggle pull-right verification-btn" type="button" data-toggle="dropdown">
          INVALID
          <span class="caret"></span>
        </button>
        <ul id="tableMenu" class="dropdown-menu">
            <li> Not clear </li>
            <li> not valid </li>
            <li> other </li>
        </ul>
      </div>
      <div class="rejection-reason" style="display: none">

          <input class="rejection-reason-text" type="hidden" name="obs_application[panels][documents][sg_lta_vehicle_log_card][rejection_reasons][vehicleType]" id="obs_application_panels_documents_sg_lta_vehicle_log_card_rejection_reasons_vehicleType">
        <span class="rejection-reason-text"></span>
        <div class="other-reason-text-block">
        </div>
      </div>

    </div>
    <div class="col-md-4 valid pull-right">
      <button id="tableButton" type="button" class="btn btn-valid pull-right verification-btn "> VALID </button>
    </div>
  </div>
  <div class="row reject-reason-other-block" style="display: none">
    <div class="col-md-12">
      <div class="modal-content">
        <div class="modal-header">
          Enter reason
        </div>
        <div class="modal-body">
          <input type="text" class="other-reason-text" maxlength="100">
        </div>
        <div class="modal-footer">
          <a class="btn btn-valid-visited other-reason-cancel">Cancel</a>
          <a class="btn btn-valid-visited other-reason-submit">Submit</a>
        </div>
      </div>
    </div>
  </div>
</div>

  </div>
</div>

                  <div class="row verification-buttons row-bordered mandatory-action-false border-blank-false">
  <div class="col-md-6">
    <div class="label"> vehicle brand: </div>

    <div class="verification-value">Alfa Romeo</div>

  </div>
  <div class="col-md-6 mandatory-action-false}">
            <div class="row component-validation" id="vehicleBrand">
  <input type="hidden" value="vehicleBrand" class="component-field">
  <div class="row verification-buttons display-block">
    <div class="col-md-8 invalid ">
      <div id="tableDiv" class="dropdown">
        <button id="tableButton" class="btn btn-invalid dropdown-toggle pull-right verification-btn" type="button" data-toggle="dropdown">
          INVALID
          <span class="caret"></span>
        </button>
        <ul id="tableMenu" class="dropdown-menu">
            <li> Not clear </li>
            <li> not valid </li>
            <li> other </li>
        </ul>
      </div>
      <div class="rejection-reason" style="display: none">

          <input class="rejection-reason-text" type="hidden" name="obs_application[panels][documents][sg_lta_vehicle_log_card][rejection_reasons][vehicleBrand]" id="obs_application_panels_documents_sg_lta_vehicle_log_card_rejection_reasons_vehicleBrand">
        <span class="rejection-reason-text"></span>
        <div class="other-reason-text-block">
        </div>
      </div>

    </div>
    <div class="col-md-4 valid pull-right">
      <button id="tableButton" type="button" class="btn btn-valid pull-right verification-btn "> VALID </button>
    </div>
  </div>
  <div class="row reject-reason-other-block" style="display: none">
    <div class="col-md-12">
      <div class="modal-content">
        <div class="modal-header">
          Enter reason
        </div>
        <div class="modal-body">
          <input type="text" class="other-reason-text" maxlength="100">
        </div>
        <div class="modal-footer">
          <a class="btn btn-valid-visited other-reason-cancel">Cancel</a>
          <a class="btn btn-valid-visited other-reason-submit">Submit</a>
        </div>
      </div>
    </div>
  </div>
</div>

  </div>
</div>

                  <div class="row verification-buttons row-bordered mandatory-action-false border-blank-false">
  <div class="col-md-6">
    <div class="label"> No Polisi: </div>

    <div class="verification-value">sj111k</div>

  </div>
  <div class="col-md-6 mandatory-action-false}">
            <div class="row component-validation" id="vehicle_plate_number">
  <input type="hidden" value="vehicle_plate_number" class="component-field">
  <div class="row verification-buttons display-block">
    <div class="col-md-8 invalid ">
      <div id="tableDiv" class="dropdown">
        <button id="tableButton" class="btn btn-invalid dropdown-toggle pull-right verification-btn" type="button" data-toggle="dropdown">
          INVALID
          <span class="caret"></span>
        </button>
        <ul id="tableMenu" class="dropdown-menu">
            <li> Not clear </li>
            <li> not valid </li>
            <li> other </li>
        </ul>
      </div>
      <div class="rejection-reason" style="display: none">

          <input class="rejection-reason-text" type="hidden" name="obs_application[panels][documents][sg_lta_vehicle_log_card][rejection_reasons][vehicle_plate_number]" id="obs_application_panels_documents_sg_lta_vehicle_log_card_rejection_reasons_vehicle_plate_number">
        <span class="rejection-reason-text"></span>
        <div class="other-reason-text-block">
        </div>
      </div>

    </div>
    <div class="col-md-4 valid pull-right">
      <button id="tableButton" type="button" class="btn btn-valid pull-right verification-btn "> VALID </button>
    </div>
  </div>
  <div class="row reject-reason-other-block" style="display: none">
    <div class="col-md-12">
      <div class="modal-content">
        <div class="modal-header">
          Enter reason
        </div>
        <div class="modal-body">
          <input type="text" class="other-reason-text" maxlength="100">
        </div>
        <div class="modal-footer">
          <a class="btn btn-valid-visited other-reason-cancel">Cancel</a>
          <a class="btn btn-valid-visited other-reason-submit">Submit</a>
        </div>
      </div>
    </div>
  </div>
</div>

  </div>
</div>

                  <div class="row verification-buttons row-bordered mandatory-action-true border-blank-true">
  <div class="col-md-6">
    <div class="label"> Vehicle Image*:</div>
    <div class="image-container">
  <div class="zoomable">
      <img src="https://sample_url/image.png">
      <input type="hidden" name="resubmit_status[Rotate]" id="resubmit_status_Rotate" value="0" class="image-rotation-input">
  </div>
  <div class="image-controller">
    <div class="fa fa-undo"></div>
    <div class="fa fa-repeat"></div>
  </div>
</div>

  </div>
  <div class="col-md-6 ">
        <div class="row component-validation" id="">
  <input type="hidden" value="" class="component-field">
  <div class="row verification-buttons display-block">
    <div class="col-md-8 invalid ">
      <div id="tableDiv" class="dropdown">
        <button id="tableButton" class="btn btn-invalid dropdown-toggle pull-right verification-btn" type="button" data-toggle="dropdown">
          INVALID
          <span class="caret"></span>
        </button>
        <ul id="tableMenu" class="dropdown-menu">
            <li> unclear image </li>
            <li> wrong image </li>
            <li> other </li>
        </ul>
      </div>
      <div class="rejection-reason" style="display: none">

          <input class="rejection-reason-text" type="hidden" name="obs_application[panels][documents][sg_lta_vehicle_log_card][rejection_reasons][]" id="obs_application_panels_documents_sg_lta_vehicle_log_card_rejection_reasons_">
        <span class="rejection-reason-text"></span>
        <div class="other-reason-text-block">
        </div>
      </div>

    </div>
    <div class="col-md-4 valid pull-right">
      <button id="tableButton" type="button" class="btn btn-valid pull-right verification-btn "> VALID </button>
    </div>
  </div>
  <div class="row reject-reason-other-block" style="display: none">
    <div class="col-md-12">
      <div class="modal-content">
        <div class="modal-header">
          Enter reason
        </div>
        <div class="modal-body">
          <input type="text" class="other-reason-text" maxlength="100">
        </div>
        <div class="modal-footer">
          <a class="btn btn-valid-visited other-reason-cancel">Cancel</a>
          <a class="btn btn-valid-visited other-reason-submit">Submit</a>
        </div>
      </div>
    </div>
  </div>
</div>

  </div>
</div>

    </div>
  </div>
</div>


<div class="panel">
  <div class="panel-heading">
    <div class="label">Bank</div>
  </div>
  <div class="panel-body">
    <div class="container">


              <input value="e4c987fb-a875-420e-81db-45a8482d36eb" type="hidden" name="obs_application[panels][documents][sg_bank_statement][id]" id="obs_application_panels_documents_sg_bank_statement_id">
                  <div class="row verification-buttons row-bordered mandatory-action-true border-blank-false">
  <div class="col-md-6">
    <div class="label"> bank code*: </div>

    <div class="verification-value">700003</div>

  </div>
  <div class="col-md-6 mandatory-action-true}">
            <div class="row component-validation" id="bank_code">
  <input type="hidden" value="bank_code" class="component-field">
  <div class="row verification-buttons display-block">
    <div class="col-md-8 invalid ">
      <div id="tableDiv" class="dropdown">
        <button id="tableButton" class="btn btn-invalid dropdown-toggle pull-right verification-btn" type="button" data-toggle="dropdown">
          INVALID
          <span class="caret"></span>
        </button>
        <ul id="tableMenu" class="dropdown-menu">
            <li> Not clear </li>
            <li> not valid </li>
            <li> other </li>
        </ul>
      </div>
      <div class="rejection-reason" style="display: none">

          <input class="rejection-reason-text" type="hidden" name="obs_application[panels][documents][sg_bank_statement][rejection_reasons][bank_code]" id="obs_application_panels_documents_sg_bank_statement_rejection_reasons_bank_code">
        <span class="rejection-reason-text"></span>
        <div class="other-reason-text-block">
        </div>
      </div>

    </div>
    <div class="col-md-4 valid pull-right">
      <button id="tableButton" type="button" class="btn btn-valid pull-right verification-btn "> VALID </button>
    </div>
  </div>
  <div class="row reject-reason-other-block" style="display: none">
    <div class="col-md-12">
      <div class="modal-content">
        <div class="modal-header">
          Enter reason
        </div>
        <div class="modal-body">
          <input type="text" class="other-reason-text" maxlength="100">
        </div>
        <div class="modal-footer">
          <a class="btn btn-valid-visited other-reason-cancel">Cancel</a>
          <a class="btn btn-valid-visited other-reason-submit">Submit</a>
        </div>
      </div>
    </div>
  </div>
</div>

  </div>
</div>

                  <div class="row verification-buttons row-bordered mandatory-action-true border-blank-false">
  <div class="col-md-6">
    <div class="label"> account number*: </div>

    <div class="verification-value">5367683475661</div>

  </div>
  <div class="col-md-6 mandatory-action-true}">
            <div class="row component-validation" id="account_number">
  <input type="hidden" value="account_number" class="component-field">
  <div class="row verification-buttons display-block">
    <div class="col-md-8 invalid ">
      <div id="tableDiv" class="dropdown">
        <button id="tableButton" class="btn btn-invalid dropdown-toggle pull-right verification-btn" type="button" data-toggle="dropdown">
          INVALID
          <span class="caret"></span>
        </button>
        <ul id="tableMenu" class="dropdown-menu">
            <li> Not clear </li>
            <li> not valid </li>
            <li> other </li>
        </ul>
      </div>
      <div class="rejection-reason" style="display: none">

          <input class="rejection-reason-text" type="hidden" name="obs_application[panels][documents][sg_bank_statement][rejection_reasons][account_number]" id="obs_application_panels_documents_sg_bank_statement_rejection_reasons_account_number">
        <span class="rejection-reason-text"></span>
        <div class="other-reason-text-block">
        </div>
      </div>

    </div>
    <div class="col-md-4 valid pull-right">
      <button id="tableButton" type="button" class="btn btn-valid pull-right verification-btn "> VALID </button>
    </div>
  </div>
  <div class="row reject-reason-other-block" style="display: none">
    <div class="col-md-12">
      <div class="modal-content">
        <div class="modal-header">
          Enter reason
        </div>
        <div class="modal-body">
          <input type="text" class="other-reason-text" maxlength="100">
        </div>
        <div class="modal-footer">
          <a class="btn btn-valid-visited other-reason-cancel">Cancel</a>
          <a class="btn btn-valid-visited other-reason-submit">Submit</a>
        </div>
      </div>
    </div>
  </div>
</div>

  </div>
</div>

                  <div class="row verification-buttons row-bordered mandatory-action-false border-blank-false">
  <div class="col-md-6">
    <div class="label"> account holder name: </div>

    <div class="verification-value">Testing</div>

  </div>
  <div class="col-md-6 mandatory-action-false}">
  </div>
</div>

                  <div class="row verification-buttons row-bordered mandatory-action-true border-blank-true">
  <div class="col-md-6">
    <div class="label"> Bank Image*:</div>
    <div class="image-container">
  <div class="zoomable">
      <img src="http://sample_url/image.png">
      <input type="hidden" name="resubmit_status[Rotate]" id="resubmit_status_Rotate" value="0" class="image-rotation-input">
  </div>
  <div class="image-controller">
    <div class="fa fa-undo"></div>
    <div class="fa fa-repeat"></div>
  </div>
</div>

  </div>
  <div class="col-md-6 ">
        <div class="row component-validation" id="">
  <input type="hidden" value="" class="component-field">
  <div class="row verification-buttons display-block">
    <div class="col-md-8 invalid ">
      <div id="tableDiv" class="dropdown">
        <button id="tableButton" class="btn btn-invalid dropdown-toggle pull-right verification-btn" type="button" data-toggle="dropdown">
          INVALID
          <span class="caret"></span>
        </button>
        <ul id="tableMenu" class="dropdown-menu">
            <li> unclear image </li>
            <li> wrong image </li>
            <li> other </li>
        </ul>
      </div>
      <div class="rejection-reason" style="display: none">

          <input class="rejection-reason-text" type="hidden" name="obs_application[panels][documents][sg_bank_statement][rejection_reasons][]" id="obs_application_panels_documents_sg_bank_statement_rejection_reasons_">
        <span class="rejection-reason-text"></span>
        <div class="other-reason-text-block">
        </div>
      </div>

    </div>
    <div class="col-md-4 valid pull-right">
      <button id="tableButton" type="button" class="btn btn-valid pull-right verification-btn "> VALID </button>
    </div>
  </div>
  <div class="row reject-reason-other-block" style="display: none">
    <div class="col-md-12">
      <div class="modal-content">
        <div class="modal-header">
          Enter reason
        </div>
        <div class="modal-body">
          <input type="text" class="other-reason-text" maxlength="100">
        </div>
        <div class="modal-footer">
          <a class="btn btn-valid-visited other-reason-cancel">Cancel</a>
          <a class="btn btn-valid-visited other-reason-submit">Submit</a>
        </div>
      </div>
    </div>
  </div>
</div>

  </div>
</div>

    </div>
  </div>
</div>

                            <div class="submit-btn-verification">
  <input type="submit" name="commit" value="Submit/Done" class="submit_btn btn btn-valid disabled" disabled="disabled" style="cursor: not-allowed">
</div>

</form>

这是erb中的表格:

            <% if (!@application_completed.nil? && !@application_completed) %>
                <%= form_for @application, url: retry_application_completion_app_agent_v2_verification_path, method: :post, html: { id: 'verification-form', class: 'col-md-6 text-center' } do |f| %>
                    <%= f.hidden_field :id, value: @application.id %>
                    <%= f.submit 'Retry', formaction: retry_application_completion_app_agent_v2_verification_path, class: 'btn btn-valid pull-right' %>
                <% end %>
            <% else %>
                <% panels = @layout.panels %>
                <%= form_for @application, url: submit_app_agent_v2_verification_path, method: :post, html: { id: 'verification-form' } do |f| %>
                    <%= f.hidden_field :operation_name, value: @layout.name %>
                    <%= f.hidden_field :application_id, value: @application.id %>

                    <% if @application.resubmit? %>
                        <div class="resubmit-header">RESUBMITTED APPLICATION</div>
                    <% end %>

                    <%= f.fields_for :panels do |form| %>
                        <% panels.each do |panel| %>
                            <%= render partial: 'partials/agent/v2/verifications/panels/' + panel.type.underscore, locals: { panel: panel, form: form } %>
                        <% end %>
                    <% end %>
                <% end %>
                </div>
            <% end %>

将此作为_submit_panel的erb部分:

<% sections = panel.sections %>
<div class="submit-btn-verification">
  <%= form.submit sections.first.properties['label'], class: 'submit_btn btn btn-valid disabled', disabled: 'disabled', style: 'cursor: not-allowed' %>
</div>

0 个答案:

没有答案