Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jQuery fileupload插件时出现TypeError(不能将符号转换为整数)_Jquery_Ruby On Rails 3_Jquery Plugins - Fatal编程技术网

使用jQuery fileupload插件时出现TypeError(不能将符号转换为整数)

使用jQuery fileupload插件时出现TypeError(不能将符号转换为整数),jquery,ruby-on-rails-3,jquery-plugins,Jquery,Ruby On Rails 3,Jquery Plugins,我正在使用jqueryfileupload插件上传多张图片。检查发送到服务器的数据,它是: Parameters: {"utf8"=>"✓", "authenticity_token"=>"pE6KRzQv05wwcutCRN0UlZ3Cy39cNAtEYCMbkoVtwBQ=", "poll"=>{"title"=>"fjijgg", "category"=>"1", "items_attributes"=>{"brand"=>"item 3", "p

我正在使用jqueryfileupload插件上传多张图片。检查发送到服务器的数据,它是:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"pE6KRzQv05wwcutCRN0UlZ3Cy39cNAtEYCMbkoVtwBQ=", "poll"=>{"title"=>"fjijgg", "category"=>"1", "items_attributes"=>{"brand"=>"item 3", "photo"=>[#<ActionDispatch::Http::UploadedFile:0x007fe609c377a0 @original_filename="Photo Nov 20, 1 19 44 AM.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"poll[items_attributes[photo]][]\"; filename=\"Photo Nov 20, 1 19 44 AM.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/3s/xggrbr6119v_mtcqn9r0b6tr0000gn/T/RackMultipart20121120-1465-d21tys>>]}}}
我认为这是由“items_attributes”=>{…}引起的。关于如何修复它有什么建议吗


谢谢

我发现,由于它是一对多关联,也就是说,poll有很多项,它应该看起来像“items\u attributes”=>[{..}],而不是“items\u attributes”=>{..}

我发现,因为它是一对多关联,即poll有很多项,所以它应该看起来像“items\u attributes”=>[{..},而不是“项目属性”=>{..}

class Item < ActiveRecord::Base
  attr_accessible :photo, :photo_url, :poll_id, :brand, :number_of_votes,:description, :is_deleted
  has_attached_file :photo,
                    :styles => { :thumbnail => "100x100#",
                                   :small => "150x150>",
                                   :medium => "250x250>",
                                   :large => "400x400>" },
                    :storage => :s3,
                    :s3_credentials => S3_CREDENTIALS,
                    :url=>"/item_:id/created_at_:created_at/:style.jpg"
  belongs_to :poll
end

class Poll < ActiveRecord::Base
    attr_accessible :title, :user_id, :category, :items_attributes
    belongs_to :user
    has_many :items, :dependent => :destroy
    accepts_nested_attributes_for :items
    default_scope :order => 'polls.created_at DESC'
end
class PollsController < ApplicationController
  def create
    @poll=Poll.create(params[:poll])
    redirect_to @poll
  end
end
TypeError (can't convert Symbol into Integer):