Html表单不包括在post';s参数文件数据

Html表单不包括在post';s参数文件数据,html,ruby-on-rails,forms,file,post,Html,Ruby On Rails,Forms,File,Post,出于我甚至猜不到的原因,我的rails应用程序不再工作了。我没有改变rails代码中的任何内容,所以我想可能是关于浏览器的 简单表单,由简单表单生成: <%= simple_form_for @order, :url => fillparameters_order_path(@order), :remote => true do |f| %> <%= f.association :aspectRatio, collection: @order.project

出于我甚至猜不到的原因,我的rails应用程序不再工作了。我没有改变rails代码中的任何内容,所以我想可能是关于浏览器的

简单表单,由简单表单生成:

<%= simple_form_for @order, :url => fillparameters_order_path(@order), :remote => true do |f| %>

  <%= f.association :aspectRatio,  collection: @order.project.aspect_ratios %>
  <%= f.input :client_email, :as => :string %>
  <%= f.input :soundtrack, :as => :file %>
  <%= f.input :project_id, :as => :hidden %>
  <%= f.button :submit %>
<% end %>

有什么想法吗,伙计们?

事实是:rails中的:remote=>true选项不能上传文件。有两种方法允许您使用AJAX进行文件上载:

  • rails方式:使用gem
  • Jquery方式:使用Jquery文件上传插件,有很多这样的插件,比如

    等等

  • form id="edit_order_4" class="simple_form edit_order" novalidate="novalidate" method="post" enctype="multipart/form-data" data-remote="true" action="/orders/4/fillparameters" accept-charset="UTF-8"
        <input id="order_soundtrack" class="file optional" type="file" name="order[soundtrack]">
        <input class="btn" type="submit" value="Send!" name="commit">
    
    Started PUT "/orders/4/fillparameters" for 127.0.0.1 at 2013-08-04 21:00:03 +0900
    Processing by OrdersController#fillparameters as JS
    Parameters: {
        "utf8" => "✓",
        "authenticity_token" => "VpddWLzi7Czzl0L+gbd5wVfjbJ1pQnfI53L86BwbH/E=",
        "order" => {
            "aspect_ratio_id" => "1",
            "client_email" => "****@gmail.com",
            "project_id" => "1"
        },
        "commit" => "Send!",
        "id" => "4"
    }