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. -- Posted via ruby-forum.com.
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: wiki.rubyonrails.com/rails/pages/HowtoUploadFiles It mentions that the action gets passed an object which has (among other things) a content_type() method. -- Alex
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) -- Posted via ruby-forum.com.
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 Puzzella 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?-- Posted via ruby-forum.com.
Any takers? On 4/26/06 10:39 AM, "Vince Puzzella" <vpuz@rogers.com> wrote:> 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? > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > lists.rubyonrails.org/mailman/listinfo/rails
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: rubyforge.org/projects/railsrtv On 4/27/06 10:46 AM, "Vince Puzzella" <vpuz@rogers.com> wrote:> Any takers? > > > On 4/26/06 10:39 AM, "Vince Puzzella" <vpuz@rogers.com> wrote: > >> 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? >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > lists.rubyonrails.org/mailman/listinfo/rails