úterý 11. září 2007

rails and file_column plugin: copy problem

I must solve this problem: some record with picture is created and it is necessary to create its copy. This record has image and we use file_column plugin for manipulations with this field.
Uploading of file is super, but problem began when you try to set image from local file system. I found simple and nice solution on this blog, but this solution doesn't work.
So, I made some changes to original script and you should use these simple commands.

coppied_area = Area.find(params[:coppied_area]) # original record
@area = coppied_area.clone # create copy
@area.day_foto = File.open coppied_area.day_foto unless coppied_area.day_foto.nil? # add image when existing

New file_column.rb should be downloaded here.

Žádné komentáře: