# Questions on attachment\_fu\_

**URL:** <https://www.ruby-forum.com/t/questions-on-attachment-fu/196445>\
**Category:** Rails\
**Created:** [August 24, 2007, 6:25am UTC](https://www.ruby-forum.com/t/questions-on-attachment-fu/196445 "2007-08-24T06:25:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [August 24, 2007, 6:25am UTC](https://www.ruby-forum.com/t/questions-on-attachment-fu/196445/1 "2007-08-24T06:25:40Z")

</div>

I am having a hard time saving the uploaded files to the directory of  
my choice.

There is the method full\_filename() that is said to be the one to  
override to specify a custom path, but when I do so the file is not  
saved

```auto
#Here is the original method in the file_system_backend.rb file

# Overwrite this method in your model to customize the filename.
        # The optional thumbnail argument will output the thumbnail's
filename.
        def full_filename(thumbnail = nil)
          file_system_path = (thumbnail ? thumbnail_class :
self).attachment_options[:path_prefix].to_s
          File.join(RAILS_ROOT, file_system_path,
*partitioned_path(thumbnail_name_for(thumbnail)))
        end
```

I created a custom full\_filename method in my Picture class, which was  
called on to generate the file name for the uploaded file, but when  
this method was used the file was not saved in the directory that I  
specified.

Here is the updated method within the Picture class

```auto
def full_filename(thumbnail = nil)
    file_system_path = (thumbnail ? thumbnail_class :
self).attachment_options[:path_prefix].to_s
    File.join(RAILS_ROOT, "pictures", thumbnail_name_for(thumbnail))
  end
```

I admit I am a little confused on how this method overrides the the  
one in the file\_system\_backend.rb file (I will have to read up on  
this), but for starters I just want to figure out why the files are  
not saving.

There is also an issue in the thumbnails not being created. Sometimes  
they are created as they should be, then after testing things at a  
later time, they are no longer saved.

The last thing that I am wondering about, is what is the common way to  
relate the images/files. I would think just to create an additional  
foreign key column in the table relating back to the parent table, but  
if that is the case I would have to create a couple of methods in the  
parent class, in this case Member, to retrieve a list of the  
thumbnails. That just seems like to much extra code for ruby, so I am  
thinking that there may already be something that is provided that  
will do this.

Thanks for the help.
