10th Jul, 2009

Removing extra whitespaces from string or params [Ruby on Rails]

” Arthur Neil “.squeeze(” “).strip

To find empty characters/space in a filed; use

if params[:description].squeeze(” “).strip.length == 0
[handle it here]
end

Leave a response

Your response:

Categories and Tags

Advertising