Newbie File_Column and Console Question

I recently got File_Column installed and working and it is great, but
now I find myself needing to resize all the images I already uploaded.

Through the web I found that the answer lies in going to the
script/console and adding:

Attachment.find(:all).each do |a|
a.asset = File.open(a.asset)
a.save
end

But what exactly do I do next, I tried running it with no success. How
can I make it work?

Thanks!

end

But what exactly do I do next, I tried running it with no success. How
can I make it work?

Thanks!

Here’s some more information it it will help.

The model I have is for my Products, with image as the
attribute for the file_column file.

I went into the console, and selected all of my products
that do not have a file name in the image field, so that
I would only get the products with current images.

So with that I made a loop to go through each product:

for product in @products
product.image = File.open(product.image)
product.save
end

Now the loop works, I get no errors, but every file is
loaded into the tmp folder!

After sorting through the returned array I noticed:
#<Product:0x2503acc @errors=#<ActiveRecord::Errors:0x2476500
@errors={“image”=>[“invalid image”]},

Can anyone guide me on the next step? I’ve searched everywhere
but cant seem to find a solution!

Thanks

sshefer <sshefer@…> writes:

I recently got File_Column installed and working and it is great, but
now I find myself needing to resize all the images I already uploaded.

I went into the console, and selected all of my products
that do not have a file name in the image field, so that
I would only get the products with current images. But it doesn’t seem
to create the new version, just load it into tmp dir.

Can anyone else help?

I’ve searched every conceivable place for it with no luck, is this even
possible? I’d like to know and add to the File Column HowTwo, as this
seems to
be a common question with no replies!

Anyone? Any help/guidance would be appreciated.

shai shefer wrote:

sshefer <sshefer@…> writes:

I recently got File_Column installed and working and it is great, but
now I find myself needing to resize all the images I already uploaded.

I went into the console, and selected all of my products
that do not have a file name in the image field, so that
I would only get the products with current images. But it doesn’t seem
to create the new version, just load it into tmp dir.

Can anyone else help?

I’ve searched every conceivable place for it with no luck, is this even
possible? I’d like to know and add to the File Column HowTwo, as this
seems to
be a common question with no replies!

Anyone? Any help/guidance would be appreciated.

Shai,

I believe that if you look at the File_Column docs it will tell you that
File_Column works with ImageMagick (on Linux) in order to resize images
on upload. You can even create multiple versions of the same file. I
hope this helps.

Good luck,

Rob D.

Thanks for the reply…

I looked into doing ImageMagick and running it through the console, but
was
wondering if there wasn’t a simpler, more sophisticated manner of
updating
the existing image tree with the new versions.

Is there no way to tie in the new versions set in the Model when opening
an
image and saving it?

I would think this is a common problem, did no one else need to
add/change
image sizes?

View this message in context:
http://www.nabble.com/Newbie-File_Column-and-Console-Question.-t1394748.html#a3853979
Sent from the RubyOnRails Users forum at Nabble.com.