File Column 0.1.3
I have got a new release 0.1.3 of my
file_column library. It fixes
a bug that occurs when declaring multiple columns as file_columns simultaneously
like this: “file_column :image, :another_image”.
Grab the new release for hassle-free file uploads in rails!
For all of you who are curious about the bug (I know you are!): I was iterating through the list of arguments with code like this:
def file_column(*args)
for attr in args
# a lot of meta-programming to define methods
# that refer attr in their bodies.
end
end
Unfortunately, Ruby’s “for ... in ...” construct seems to be heavily
optimized so that every element of args is copied into attr
in a way that closures don’t really work anymore. In the end, methods defined in
the second iteration of the loop refered to the first attribute.
The fix was easy: Just use “args.each do |attr|” instead, which behaves
as expected even in the presence of closures.