Ryan,

For Glenn's issue we're assuming that params[:blah] is a hash upon which you call Hash#delete_if. As for yours, params[:post] is a hash and params[:post][:blah] returns the hash value with key :blah.

-Jordan

On May 31, 2007, at 7:50 PM, Ryan Felton wrote:

Sometimes I find I have to do a params[:post][:blah]. Haven't figured out exactly why yet..

Ryan

On 5/31/07, Jordan A. Fowler < [EMAIL PROTECTED]> wrote:
Glenn,

This is a simple one liner:

params[:blah].delete_if {|k,v| v.blank?}

Cheers.

-Jordan

On May 31, 2007, at 3:51 PM, Glenn Little wrote:

We've got a situation where we're setting up params[:blah]
in a form.  When the form is submitted, we do a
Model.find(:first, :conditions => params[:blah])

This generates a SELECT with all the params, but the
problem is that if the user left some fields blank,
the WHERE conditions end up looking like

 WHERE some_field = ''

which is accepted by mysql, but fails on certain field
types ( e.g. Integer) in postgres.  What we really want
in most cases would be no specified condition at all
corresponding to blank fields, or perhaps flag an error.

Is there anything already in rails that I might be missing
that exists to deal with this situation?

Thanks...

                -glenn
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

--------------------------------------------------------------
Jordan A. Fowler
1830 Market St. #4
San Diego, CA 92102
E-mail: [EMAIL PROTECTED]
AIM: virtuosojordan
Phone: 406.546.8055




_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby


_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

--------------------------------------------------------------
Jordan A. Fowler
1830 Market St. #4
San Diego, CA 92102
E-mail: [EMAIL PROTECTED]
AIM: virtuosojordan
Phone: 406.546.8055



_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to