Validating presence of file uploads

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) = base_part_of(asset_field.original_filename)

	self.content_type = asset_field.content_type.chomp =

def base_part_of(file_name)
	#if !file_name

	name = File.basename(file_name)

	name.gsub(/[^\w._-]/, '')

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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs