hi sebastian, man, I hope you don''t mind me bothering you with all these questions... I''m working on a project where file uploads are central to the app, and so I''m using FileColumn a lot! so, I got RMagick working (after several days of pain), and now I''m getting to the part of creating thumbnails on uploads... for this, I would like to access the path to the directory where file_column is storing the final copy of the file, so that I can have rmagick write to it. my question would be: how can I adapt file_column.rb so that it would add a file_relative_dir method, like the current file_relative_path one? I''ve been studying file_column.rb, but my current ruby knowledge is less than basic, and I haven''t been able to figure this on my own.... thanks oliver
Sebastian Kanthak
2005-Sep-03 09:42 UTC
Re: (newbie) accessing file_column to save a thumbnail
Hi Oliver, On 8/31/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> man, I hope you don''t mind me bothering you with all these > questions... I''m working on a project where file uploads are central > to the app, and so I''m using FileColumn a lot!I''m glad it is of use to you.> so, I got RMagick working (after several days of pain), and now I''m > getting to the part of creating thumbnails on uploads... > > for this, I would like to access the path to the directory where > file_column is storing the final copy of the file, so that I can have > rmagick write to it. > > my question would be: how can I adapt file_column.rb so that it would > add a file_relative_dir method, like the current file_relative_path > one? I''ve been studying file_column.rb, but my current ruby knowledge > is less than basic, and I haven''t been able to figure this on my own....If your column is named "image", @photo.image will give you a string with the file''s absolute path. You can use Ruby''s File#dirname method to get the directory. I suggest you generate the thumbnail in an after-save callback, as the final directory cannot be created earlier as it contains the primary key. This is one of the things I want to support better in a future release. So stay tuned. Sebastian
oliver barnes
2005-Sep-05 18:48 UTC
Re: (newbie) accessing file_column to save a thumbnail
hey sebastian, afterall I ended up going the after_save way you mentioned, and almost got it working now... I posted the glitches on another thread. will definetly stay tuned, and anything I could do to help in your work with FC, please let me know, I''d be glad to contribute in some way if I can. thanks oliver On Sep 3, 2005, at 6:42 AM, Sebastian Kanthak wrote:> Hi Oliver, > > On 8/31/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> man, I hope you don''t mind me bothering you with all these >> questions... I''m working on a project where file uploads are central >> to the app, and so I''m using FileColumn a lot! >> > > I''m glad it is of use to you. > > >> so, I got RMagick working (after several days of pain), and now I''m >> getting to the part of creating thumbnails on uploads... >> >> for this, I would like to access the path to the directory where >> file_column is storing the final copy of the file, so that I can have >> rmagick write to it. >> >> my question would be: how can I adapt file_column.rb so that it would >> add a file_relative_dir method, like the current file_relative_path >> one? I''ve been studying file_column.rb, but my current ruby knowledge >> is less than basic, and I haven''t been able to figure this on my >> own.... >> > > If your column is named "image", @photo.image will give you a string > with the file''s absolute path. You can use Ruby''s File#dirname method > to get the directory. I suggest you generate the thumbnail in an > after-save callback, as the final directory cannot be created earlier > as it contains the primary key. > > This is one of the things I want to support better in a future > release. So stay tuned. > > Sebastian >