Abhishek Abhishek - 6 months ago 13
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

Location.TRIM(name)


But it isnt working. is the query wrong?

Answer

This is what you are looking for:

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