I have a Rails 3.2.14 app where I collect data values through a typical form. There are times when staff members will enter a field such as name as " Doe, John " Where the format should be "Doe, John". Or in other instances they may add an address to the form such as " 111 W. 8th St Houston, TX 77448 " instead of "111 W. 8th St Houston, TX 77448".
So basically they are doing a lot of cutting and pasting which at times includes leading and trailing whitespace.
I'm somewhat familiar with strip
but I'm not sure now I can strip just the leading and trailing whitespace.
I'd like to make this a validation or a callback before_save or before_create filter.
If anyone has any advice on how to strip the leading/trailing whitespaces and what that validation or method would look like I'd appreciate it.