not sure whats going on here, but I’m using some pretty standard code to
manage file uploads in to a db, but having trouble detecting if the file
upload field has been filled or not.
in my Asset Model, I have:
def asset=(asset_field)
self.name = base_part_of(asset_field.original_filename)
self.content_type = asset_field.content_type.chomp
self.data = asset_field.read
end
def base_part_of(file_name)
#if !file_name
#end
name = File.basename(file_name)
name.gsub(/[^\w._-]/, '')
end
and my form has an file input field like:
<%= file_field(“asset”, “asset”) %>
If I put in my model validates_presence_of :asset, then the upload
doesnt create a new record, even if I specify a file, so somethings not
working…any clues or workarounds?