Immediate help needed

I have posted this previously also but haven’t received any help.
So, if somebody could look into it and guide…
I want to validate the extension of files that I am uploading.
Like I want only the doc/pdf files to be uploaded…

Thanks in advance.

Jp wrote:

I have posted this previously also but haven’t received any help.
So, if somebody could look into it and guide…
I want to validate the extension of files that I am uploading.
Like I want only the doc/pdf files to be uploaded…
I believe this page may be of assistance:

http://wiki.rubyonrails.com/rails/pages/HowtoUploadFiles

It mentions that the action gets passed an object which has (among other
things) a content_type() method.

Hi Folks,

I just noticed something odd with observe_form after updating from rails
1.0.0 to 1.1.2

It seems as though the first form field is always omitted from the ajax
request parameters. However, the request does contain an entry like
this:
“Form.serialize(“some_form”)”=>“some_model[the_first_form_field]=some_valu
e”

My call to observe_form produces the following javascript:

new Form.EventObserver(‘some_form’, function(element, value) {new
Ajax.Request(’/some_model/some_action’, {asynchronous:true,
evalScripts:true,
onComplete:function(request){eval(request.responseText)},
parameters:‘Form.serialize(“some_form”)=’ + value})})

Has anybody experienced similar behavior?

Yes, I have noticed the exact same thing. Here’s the hack/workaround
that works for me:

Change the observe_form call to include:
:with => “foo = Form.serialize(‘some_form’)”

The "foo = " causes rails to lop off that extraneous ‘=’ at the end.

Cheers,
Craig

Vince P. wrote:

I just noticed something odd with observe_form after updating from rails
1.0.0 to 1.1.2

It seems as though the first form field is always omitted from the ajax
request parameters. However, the request does contain an entry like
this:
“Form.serialize(“some_form”)”=>“some_model[the_first_form_field]=some_valu
e”

-snip-

Has anybody experienced similar behavior?

Any takers?

Hi Folks,
I developed a realtime form validation plugin. It uses AJAX to validate
from data on the fly.

The DOM is dynamically modified as the user enters form data. Form
fields
are wrapped with span elements which can be styled using CSS.

See the readme.txt file for more info.

You can get it here: http://rubyforge.org/projects/railsrtv/

Jp wrote:

I have posted this previously also but haven’t received any help.
So, if somebody could look into it and guide…
I want to validate the extension of files that I am uploading.
Like I want only the doc/pdf files to be uploaded…

Thanks in advance.

Regular expressions.

if filename =~ /(.doc|.pdf)$/
#accept the upload
else
#discard file
end

(That regular expression I wrote is probably not perfect. Look around
for better examples)