Paperclip exception : Paperclip::AdapterRegistry::NoHandlerError Paperclip exception : Paperclip::AdapterRegistry::NoHandlerError ruby-on-rails ruby-on-rails

Paperclip exception : Paperclip::AdapterRegistry::NoHandlerError


This Error is raised because you aren't giving Paperclip a correct class. It's a just a String.

You should receive something like this in params

"asset"=>  {"image"=>    #<ActionDispatch::Http::UploadedFile:0x000000056679e8    @content_type="image/jpg",    @headers= "Content-Disposition: form-data; name=\"asset[image]\";      filename=\"2009-11-29-133527.jpg\"\r\nContent-Type: image/jpg\r\n",    @original_filename=""2009-11-29-133527.jpg"",    @tempfile=#<File:/tmp/RackMultipart20120619-1043-yvc9ox>>}

And you should have something like this in yout View (in HAML, very simplified):

= form_for @product, html: { multipart: true } do |f|  = f.fields_for :asset do |asset_form|    = asset_form.file_field :image

Remember to set your form to multipart: true.


I just ran into this problem myself. In my case it was caused by skipping the multipart form declaration in the markup.

I was using formtastic so I added this and got it working:

semantic_form_for @picture, :html => {:multipart => true} do |f|


Note there is a situation when working with an HTML5 canvas that is worth noting. Getting the canvas data as a DataURI string and sending that to server can cause this error. Canvas .toDataURL() will give something like "data:image/png;base64,iVBORw0KGg..." which you can send to server with other information, so its different than a standard multi-part form upload. On the server side if you just set this to the paperclip attachment field you will get this error. You need to conver it to a file or IO object. You could write a temp file like this:

data_uri = params[:canvasDataUri]encoded_image = data_uri.split(",")[1]decoded_image = Base64.decode64(encoded_image)File.open("signature.png", "wb") { |f| f.write(decoded_image) }

or use Ruby's StringIO which acts like an in memory file interface

@docHolder.document = StringIO.new(decoded_image)

Hope this helps.