before_save :strip_whitespace => saves with spaces

i used this private function for removing leading and trailing white spaces from the values.that below function would be called before_save. when i print the value after it strips.it prints string without any spaces.but in the table fields it saves with spaces . waht would be the problem.pls help me

because when you do

value = value.strip

you're not stripping whitespace from value. You are creating a new string object that has been stripped. The @attributes hash still contains the unstripped version.

Fred

Thanks for the reply. Could you tell me the way of implementation pls. How can i resolve it.

Thanks in advance

Newb Newb wrote:

Thanks for the reply. Could you tell me the way of implementation pls. How can i resolve it.

Thanks in advance    change line   value = value.strip to:   self[attr] = value.strip