Ruby on rails 参数未随jquery文件上载一起发送

Ruby on rails 参数未随jquery文件上载一起发送,ruby-on-rails,ajax,jquery,ruby-on-rails-4,jquery-file-upload,Ruby On Rails,Ajax,Jquery,Ruby On Rails 4,Jquery File Upload,出于某种原因,我的查询文件上载ajax表单出现以下错误: ActionController::ParameterMissing (param not found: profile): app/controllers/profiles_controller.rb:146:in `profile_params' app/controllers/profiles_controller.rb:52:in `create' 以下是发送的参数: Parameters: {"utf8"=&g

出于某种原因,我的查询文件上载ajax表单出现以下错误:

ActionController::ParameterMissing (param not found: profile):
    app/controllers/profiles_controller.rb:146:in `profile_params'
    app/controllers/profiles_controller.rb:52:in `create'
以下是发送的参数:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"fdsahKJAHLSJFJAHFAS323FDSGF4="}
因此,由于某些原因,配置文件参数没有被发送。这是我的表格:

<%= form_for @profile, :html => { :class => "clearfix", :id => "the_form"},
    remote: true do |f| %>
    <%= f.file_field :pic, name: 'profile[pic]', :class => "field file-field",
    :id => "file", :multiple => true %>
<% end %>
下面是profiles#加载表单的新操作:

def new
    @profile = Profile.new
@skills = Skill.all.collect {|skill| skill.label} #this is for something else on the page
end
另外,这里是获取表单的coffee脚本文件。因为表单是通过ajax呈现的,所以我需要使用ajaxcomplete方法

jQuery ->
  $(document).ajaxComplete ->
    $('#the_form').fileupload
      dataType: "script"
      add: (e, data) ->
        types = /(\.|\/)(gif|jpe?g|png)$/i
        file = data.files[0]
        if types.test(file.type) || types.test(file.name)
          data.submit()
        else
          alert("#{file.name} is not a gif, jpeg, or png image file")
      done: (e, data) ->
        $('#finish-text').html "Upload finished"
我知道咖啡脚本是有效的,因为它与另一种形式协同工作


为什么没有发送配置文件参数?

在表单中添加:multipart=>true,因为表单中有文件上载字段

例如:

<%= form_for @profile, :html => { :class => "clearfix", :id => "the_form", :multipart => true}, remote: true do |f| %> {:class=>“clearfix”,:id=>“theu form”,:multipart=>true},remote:true do | f |%> <%= form_for @profile, :html => { :class => "clearfix", :id => "the_form", :multipart => true}, remote: true do |f| %>