我试图通过使用回形针的ajax上传图像。回形针重复的网址错误
我使用qqfileuploader为ajax的东西,它似乎没有一个选项,我可以定义发布请求的参数名称。
从阿贾克斯后发送的参数是
qqfile=filename.jpg
所以在我的模型,我别名qqfile到照片
alias_attribute :qqfile, :photo has_attached_file :photo attr_accessible :title, :photo
当我上传通过AJAX的文件时,我得到以下错误
Parameters: {"qqfile"=>"Penguins.jpg"} WARNING: Can't verify CSRF token authenticity Creating scope :page. Overwriting existing method User.page. User Load (1.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1 Creating scope :page. Overwriting existing method RoleUser.page. Creating scope :page. Overwriting existing method Role.page. Role Load (1.4ms) SELECT `roles`.* FROM `roles` INNER JOIN `role_users` ON `roles`.`id` = `role_users`.`role_id` WHERE `role_users`.`user_id` = 1 SQL (0.7ms) BEGIN Creating scope :page. Overwriting existing method Task.page. [paperclip] Duplicate URL for photo with /system/:attachment/:id/:style/:filename. This will clash with attachment defined in Recipe class
我不知道,如果CSRF令牌将是一个问题,还有就是对网页上的标记,S o也许我只需要发送,我想我可以得到它是一个JavaScript的变量?
但是,重复的URL的处理是什么?我没有正确的别名?由于某种原因,我可以不使用回形针对象吗?
我的控制也很简单
def create @recipe = Recipe.new(params[:recipe]) @recipe.author_id=current_user.id if @recipe.save return render :json => @recipe else return render :text => 'an error occured saving the recipe' end end
你能提供(全部)'has_attached_file'的确切调用吗? – moritz 2012-01-04 14:10:04
@mosch,我添加了has_attached_file和attr_accessible,这只是我所知道的基础知识。 – pedalpete 2012-01-04 14:29:02