Loading with a paper clip, sinatra and mangoids

I have a problem with a paper clip with Sinatra and Mangoid. When loading, the following error is displayed:

Paperclip::AdapterRegistry::NoHandlerError - No handler found for {"tempfile"=>#, "filename"=>"image-[Converted].jpg", "content_type"=>"image/jpeg", "size"=>35222}: 

In the model, I left:

 class User include Mongoid::Document include Mongoid::Paperclip has_mongoid_attached_file :avatar, :path => ':attachment/:id/:style.:extension', :default_url => '/images/missing_portrait_:style.jpg', :styles => { :original => '1920x1680>', :small => '100x100#', :medium => '250x250', :large => '500x500>' } end
class User include Mongoid::Document include Mongoid::Paperclip has_mongoid_attached_file :avatar, :path => ':attachment/:id/:style.:extension', :default_url => '/images/missing_portrait_:style.jpg', :styles => { :original => '1920x1680>', :small => '100x100#', :medium => '250x250', :large => '500x500>' } end 

And the route / upload is as follows:

  post '/ upload' do
   User.create!  :: avatar => to_paperclip (params [: file])
 end

 def to_paperclip (image)
   paperclip = {}
   paperclip ['tempfile'] = image [: tempfile]
   paperclip ['filename'] = image [: filename]
   paperclip ['content_type'] = image [: type]
   paperclip ['size'] = image [: tempfile] .size
   paperclip  
 end

How can i solve this?

+4
source share
2 answers

I did not find a solution with a paper clip, but in the end I used a carrier wave, and it worked, what I need.

0
source

It works for me

 user = User.new() user.avatar = params[:avatar][:tempfile] user.avatar_file_name = params[:avatar][:filename] 
0
source

All Articles