# Attachement\_fu error when updating existing photos

**URL:** <https://www.ruby-forum.com/t/attachement-fu-error-when-updating-existing-photos/191398>\
**Category:** Rails\
**Created:** [July 12, 2010, 1:49am UTC](https://www.ruby-forum.com/t/attachement-fu-error-when-updating-existing-photos/191398 "2010-07-12T01:49:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![circlefusion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ea666f/32.png) [@circlefusion](https://www.ruby-forum.com/u/circlefusion)\
**Post date:** [July 12, 2010, 1:49am UTC](https://www.ruby-forum.com/t/attachement-fu-error-when-updating-existing-photos/191398/1 "2010-07-12T01:49:28Z")

</div>

Hi,

I am attempting to replace an exiting photo with a new one uploaded by  
the user. I am using attachment\_fu and I am coming up with the  
following exception:

can’t convert nil into String

/vendor/plugins/attachment\_fu/lib/technoweenie/attachment\_fu/backends/file\_system\_backend.rb:23:in  
`join' /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb:23:in`full\_filename’  
/vendor/plugins/attachment\_fu/lib/technoweenie/attachment\_fu.rb:369:in  
`temp_paths' /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:354:in`uploaded\_data=’

My ruby code:  
\<% form\_for(@photo) do |f| %\>  
\<%= f.error\_messages %\>

\<%= image\_tag(@photo.public\_filename, :BORDER=\>0) %\>

Upload new photo: \<%= f.file\_field :uploaded\_data %\> \<%= f.submit 'Update' %\>

\<% end %\>

My rails code:  
def edit  
@photo = Photo.find(params[:id])  
end

def update  
@photo = Photo.find(params[:id])

if @photo.update\_attributes(params[:photo])  
flash[:notice] = ‘Photo was successfully updated.’  
redirect\_to(’/listingHome/active/edit/’ + @photo.lisitng\_id)  
end  
end

Method failing in attachement\_fu

# Gets the full path to the filename in this format:

# 

# # This assumes a model name like MyModel

# # public/#{table\_name} is the default filesystem path

# RAILS\_ROOT/public/my\_models/5/blah.jpg

# 

# 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

Anybody have an idea what I am doing wrong?
