Validates_presence_of file fields

I can’t seem to get validates_presence_of to work with file fields. It
keeps on reporting the field is empty whether I put a file in or not. Is
there a way to validate whether a file has been uploaded?

Victor T. wrote:

I can’t seem to get validates_presence_of to work with file fields. It
keeps on reporting the field is empty whether I put a file in or not. Is
there a way to validate whether a file has been uploaded?

What is your database structure in relation to the file field?

There is a varchar field I put in by mistake, but I’m not storing
anything in it. Can that be causing the problem?

Pale H. wrote:

Victor T. wrote:

I can’t seem to get validates_presence_of to work with file fields. It
keeps on reporting the field is empty whether I put a file in or not. Is
there a way to validate whether a file has been uploaded?

What is your database structure in relation to the file field?

Victor T. wrote:

There is a varchar field I put in by mistake, but I’m not storing
anything in it. Can that be causing the problem?

Pale H. wrote:

Victor T. wrote:

I can’t seem to get validates_presence_of to work with file fields. It
keeps on reporting the field is empty whether I put a file in or not. Is
there a way to validate whether a file has been uploaded?

What is your database structure in relation to the file field?

No, that shouldn’t be causing the problem. Is it possible you can show
us the code in relation to your problem?

Victor T. wrote:

There is a varchar field I put in by mistake, but I’m not storing
anything in it. Can that be causing the problem?

Pale H. wrote:

Victor T. wrote:

I can’t seem to get validates_presence_of to work with file fields. It
keeps on reporting the field is empty whether I put a file in or not. Is
there a way to validate whether a file has been uploaded?

What is your database structure in relation to the file field?

Ah I just realised. Could the problem be I’m using form_remote_for?

Victor T. wrote:

Victor T. wrote:

There is a varchar field I put in by mistake, but I’m not storing
anything in it. Can that be causing the problem?

Pale H. wrote:

Victor T. wrote:

I can’t seem to get validates_presence_of to work with file fields. It
keeps on reporting the field is empty whether I put a file in or not. Is
there a way to validate whether a file has been uploaded?

What is your database structure in relation to the file field?

Ah I just realised. Could the problem be I’m using form_remote_for?

Try using something along the lines of:

<% remote_form_for(@class_name) do |f| %>

<% end %>