请帮帮我...我使用回形针将画布标签(base64)中的1张图片上传到aws-s3。
我的控制器
def create
decoded_file = Base64.decode64(params[:photo])
begin
file = Tempfile.new(['test', '.jpg'])
file.binmode
file.write decoded_file
file.close
@photo.photo = file
if @photo.save
render :json => {:message => "Successfully uploaded the profile picture."}
else
render :json => {:message => "Failed to upload image"}
end
ensure
file.unlink
end
end
模型
class Photo < ActiveRecord::Base
has_attached_file :photo, styles: { thumbnail: "150x200#"}, default_style: :thumbnail
end
和错误:
NoMethodError at /photos
===================================
> undefined method `stringify_keys' for #<String:0xb46dba14>
activerecord (4.0.0) lib/active_record/attribute_assignment.rb, line 17