Closed emirkin closed 10 years ago
Could this be related to https://github.com/mongoid/moped/issues/200? (@durran)
Found the problem. Not a bug.
In my case, the model with the paperclip attachment was subclassed from another model. So, when creating it I had to supply the right "type" class. I was supplying a wrong class. As a result, the ActionDispatch::Http::UploadedFile field was not intercepted by paperclip and instead was treated as an ordinary mongoid field. Naturally, it failed at the first attempt for serialization.
Hi I am getting the same problem while updating the image. What is the solution for that. my code is
clinics = Clinic.where(:id => doctor_clinic_params[:doc_clinic_id])
clinics.update(:clinic_logo => doctor_clinic_params[:clinic_logo])
class Clinic include Mongoid::Document include Mongoid::Timestamps include Mongoid::Paperclip
has_mongoid_attached_file :clinic_logo, :path => ":rails_root/public/system/:attachment/:id/:style/:filename", :url => "/system/:attachment/:id/:style/:filename", :content_type => [ "image/jpg", "image/png", "image/bmp" ], :styles => { :small => "50x50", :large => "304x304" }
end
this is my code. I am getting undefined method `bson_type' for #ActionDispatch::Http::UploadedFile:0x00000001db23f0 error. Please help me. Thanks in Advance.
undefined method `bson_type' for #ActionDispatch::Http::UploadedFile:0x00000106021618
(someone else submitted the same problem at http://stackoverflow.com/questions/22143969/undefined-method-bson-type-for-actiondispatchhttpuploadedfile0x007f9450; also, there is another similar issue here at https://github.com/meskyanichi/mongoid-paperclip/issues/34)
Here's my model:
My specs: