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:infull_filename’
/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:369:in
temp_paths' /vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:354:inuploaded_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?