Abhishek Abhishek - 1 year ago 71
Ruby Question

Ruby sql to trim an entire column in a model

I have a location model with an attribute name.
I want to trim(remove extra white spaces) the entire name attribute.

I tried to run


But it isnt working. is the query wrong?

Answer Source

This is what you are looking for:

Location.update_all('name = TRIM(name)')