carrierwaveuploader / carrierwave-mongoid

Mongoid support for CarrierWave
MIT License
355 stars 165 forks source link

Fix broken _mounter(column.to_sym).uploader #167

Closed vertis closed 5 years ago

vertis commented 8 years ago

I was getting an error when calling as_json on a model, which under the hood calls serializable_hash. I'm currently using the master version of carrierwave specifically carrierwave 0.11.0 from git://github.com/carrierwaveuploader/carrierwave.git (at master@8ceadb7).

Thing.last.serializable_hash
NoMethodError: undefined method `uploader' for #<CarrierWave::Mounter:0x007f8ac9e13b50>
Did you mean?  uploaders
    from <snip>/carrierwave-mongoid-0.10.0/lib/carrierwave/mongoid.rb:100:in `block in serializable_hash'
    from <snip>/carrierwave-mongoid-0.10.0/lib/carrierwave/mongoid.rb:98:in `each'
    from <snip>/carrierwave-mongoid-0.10.0/lib/carrierwave/mongoid.rb:98:in `serializable_hash'
    from (irb):4

I think what's happened is that carrierwave has added support for mount_uploaders (vs mount_uploader) that now supports an array of files, and under the hood changed a bunch of methods to support this. But I don't pretend to be an expert, just fixed my own version.

NB: This pull request changes the resulting behaviour from {"_id"=>..., "logo"=>{"url"=>"..."} } to {"_id"=>..., "logo"=>[{"url"=>"..."}] }

rmm5t commented 8 years ago

Thanks for the bug report and the PR attempt. Much appreciated for the effort.

However, it looks like it still needs some work considering the test suite is all red.