jnicklas/carrierwave — pull request #732 by malclocke (2012-05-02 23:55:24+00:00)
Title: Fix reference to column in serializable_hash

Serialization of AR records is broken if you have more than one uploader on a model, e.g.:

class MyModel < ActiveRecord::Base
mount_uploader :document, DocumentUploader
mount_uploader :thumbnail, ThumbnailUploader
end

m = MyModel.first

m.document
=> "/path/to/document"
m.image
=> "/path/to/image"

# This is as expected
m.as_json["thumbnail"]
=> {"url"=>"/path/to/image", ... }

# This is incorrect, has properties from the `thumbnail`, not the `document`
m.as_json["document"]
=> {"url"=>"/path/to/image", ... }

Root cause is in the class eval for `serializable_hash` the enumeration over `uploaders.each` is referencing the top level `column` var, rather than the block local `column` var from the iterator.

Solution is not ideal, as `def serializable_hash` doesn't actually need to be called in `class_eval`, and the method will get redeclared for each `mount_uploader` that is defined, but not sure how to get it called only once per model.