Rails表示提交没有一些参数

时间:2014-10-30 00:25:15

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

我的表单在“客户信息”和“送货信息”中提交没有参数。表单以模态呈现,看起来像这样

        #formShipping.modal.fade{"aria-hidden" => "true", "aria-labelledby" => "productShippingLabel", :role => "dialog", :tabindex => "-1"}
      .modal-dialog
        .modal-content
          .modal-header
            %button.close{"data-dismiss" => "modal", :type => "button"}
              %span{"aria-hidden" => "true"} ×
              %span.sr-only Close
            %h4#myModalLabel.modal-title Payment Form
          .modal-body
            / Button trigger modal
            .hide-info
              .panel.panel-default
                .panel-heading Customer Information
                .panel-body
                  .col-md-3
                  .col-md-6
                    %label{:for => "email"} Email Address
                    %input.form-control{:type => "text"}/
                    %label{:for => "name"} Name
                    %input.form-control{:type => "text"}/
                    %label{:for => "password"} Password
                    %input.form-control{:type => "text"}/
                    %label{:for => "password-confirmation"} Password confirmation
                    %input.form-control{:type => "text"}/
                  .col-md-3
            .panel.panel-default
              .panel-heading Shipping Address
              .panel-body
                .col-md-6
                  %label{:for => "name"} Name
                  %input.form-control{:type => "text"}/
                  %label{:for => "city"} City
                  %input.form-control{:type => "text"}/
                  %label{:for => "zipcode"} Zipcode
                  %input.form-control{:type => "text"}/
                .col-md-6
                  %label{:for => "address"} Address
                  %input.form-control{:type => "text"}/
                  %label{:for => "state"} State
                  %input.form-control{:type => "text"}/
                  %label{:for => "country"} Country
                  %input.form-control{:type => "text"}/
            .panel.panel-default
              .panel-heading
                %h3.panel-title Card information
              .panel-body
                .row
                  .col-md-6
                    %label{:for => "name"} Card Number
                    %input.form-control{:type => "text", "data-stripe" => "number"}/
                  .col-md-3
                    %label{:for => "name"} CVC
                    %input.form-control{:placeholder => "Ex. 331", :type => "text", "data-stripe" => "cvc"}/
                  .col-md-3
                    = label_tag :card_month, "Expiration"
                    = select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month", "data-stripe" => "exp-month"}
                    = select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year", "data-stripe" => "exp-year"}
                .text-center
                  %h2.total-amount
                    Total:
                    $0.00
                  %input{:name => "terms", :type => "CHECKBOX"}>/
                  Agree to terms?
                  %br/
                  %br
                %span.payment-errors
                %input{:name => "store_front", :type => "hidden", :value => @store_front.id}/
                .text-center
                  %button.btn.btn-primary{:type => "submit"} Pay Now!
          .modal-footer
            %button.btn.btn-default{"data-dismiss" => "modal", :type => "button"} Close

我的条纹参数完好无损。但这是检查我提交的参数的结果:

>> params
=> {"utf8"=>"✓", "authenticity_token"=>"xkgz3HdfwqS0/AfKpQteT1FaJE/LMhMneUKETCug47qhlw=",    "order_products"=>[{"product_id"=>"37", "quanity"=>"0"}, {"product_id"=>"38", "quanity"=>"1"}], "switchName1"=>"on", "custom-amount"=>"", "store_front"=>"34", "stripeToken"=>"token", "action"=>"create", "controller"=>"orders"}

有谁知道为什么我的输入没有提交?

2 个答案:

答案 0 :(得分:1)

您已忘记每个name元素的input属性。

变化:

%input.form-control{:type => "text"}/

为:

%input.form-control{:type => "text", :name =>"email"}/

并为每个元素设置正确的值。

答案 1 :(得分:1)

您已为标签指定了字段,但未指定输入,请添加

 %label{:for => "email"} Email Address
 %input.form-control{:email, :type => "text"}/