jQuery文件上载操作控制器::未知信息格式

jQuery文件上载操作控制器::未知信息格式,jquery,ruby-on-rails,file-upload,carrierwave,Jquery,Ruby On Rails,File Upload,Carrierwave,我正在尝试使用jquery fileupload rails上传多张图片 以下是我的javascript代码: <script type="text/javascript" charset="utf-8"> $(function () { // Initialize the jQuery File Upload widget: $('#fileupload').fileupload({ paramName: 'album_picture[p

我正在尝试使用jquery fileupload rails上传多张图片

以下是我的javascript代码:

<script type="text/javascript" charset="utf-8">
  $(function () {
      // Initialize the jQuery File Upload widget:
      $('#fileupload').fileupload({
        paramName: 'album_picture[picture]'
      });
      // 
      // Load existing files:
      $.getJSON($('#fileupload').prop('action'), function (files) {
        var fu = $('#fileupload').data('blueimpFileupload'), 
          template;
        fu._adjustMaxNumberOfFiles(-files.length);
        console.log(files);
        template = fu._renderDownload(files)
          .appendTo($('#fileupload .files'));
        // Force reflow:
        fu._reflow = fu._transition && template.length &&
          template[0].offsetWidth;
        template.addClass('in');
        $('#loading').remove();
      });

  });
</script>
以下是请求参数:

{"utf8"=>"✓", "authenticity_token"=>"xXkbJNMVVNy3SocUJKKHHts0RO8PEP8aGqw8C+dlaKw=", "album_picture"=>{"album_id"=>"3", "picture"=>#<ActionDispatch::Http::UploadedFile:0x007fac660e8c28 @tempfile=#<Tempfile:/var/folders/_7/jc0746b936q9b3q3lsf7xj7m0000gn/T/RackMultipart20131217-71351-1csiua>, @original_filename="gall1_big5.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"album_picture[picture]\"; filename=\"gall1_big5.jpg\"\r\nContent-Type: image/jpeg\r\n">}}
这是我的控制器代码:

def create
    @album_picture = AlbumPicture.new(album_picture_params)

    respond_to do |format|
      if @album_picture.save
        format.html {
          render :json => [@album_picture.to_jq_upload].to_json,
          :content_type => 'text/html',
          :layout => false
        }
        format.json { render json: {files: [@album_picture.to_jq_upload]}, status: :created, location: @album_picture }
      else
        format.html { render action: "new" }
        format.json { render json: @album_picture.errors, status: :unprocessable_entity }
      end
    end
  end

问题在于控制器中的Response_to块格式不正确。如果您想要更具体的答案,请发布该代码。

您应该对此进行注释,但无论如何,我也添加了控制器的代码。
ActionController::UnknownFormat (ActionController::UnknownFormat):
  app/controllers/album_pictures_controller.rb:49:in `create'

 respond_to do |format|
def create
    @album_picture = AlbumPicture.new(album_picture_params)

    respond_to do |format|
      if @album_picture.save
        format.html {
          render :json => [@album_picture.to_jq_upload].to_json,
          :content_type => 'text/html',
          :layout => false
        }
        format.json { render json: {files: [@album_picture.to_jq_upload]}, status: :created, location: @album_picture }
      else
        format.html { render action: "new" }
        format.json { render json: @album_picture.errors, status: :unprocessable_entity }
      end
    end
  end