Setting blank params to nil



Got a quick question about a before_filter routine I’m setting up in

I’m a RoR newbie coming from the PHP world and I normally “clean” POSTed
input from forms by looping through the form submission and setting any
blank strings to NULL for database processing.

I’m trying to do something similiar in Rails with the following
before_filter in my “PeopleController”

before_filter params[:person].delete_if { |key, value| value == “” } if

This (and the multiple permutations that I’ve tried) doesn’t seem to be
working, which is having the side effect of tripping any of my
validations that are set to :allow_nil

I guess I’m missing something simple because my eyes are now crossed
re-working this line of code so many times.

Any suggestions? Thanks



Arrrgh…I figured out that posting back via an AJAX form isn’t hitting
the before_filter.

I’ll have to define that as a method and call it explicitly from my AJAX
updater / inserter.