# Polite Strings

**URL:** <https://www.ruby-forum.com/t/polite-strings/100261>\
**Category:** Ruby\
**Created:** [July 28, 2006, 1:55am UTC](https://www.ruby-forum.com/t/polite-strings/100261 "2006-07-28T01:55:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [July 28, 2006, 1:55am UTC](https://www.ruby-forum.com/t/polite-strings/100261/1 "2006-07-28T01:55:32Z")

</div>

Do you have ActiveRecord classes that contain strings?

Do you sometimes put strings into those classes that are too wide for  
the database column?

Is it really suboptimal when you get a SQL error when you .save the  
object?

Are there string columns that you’d like to convert to lower case  
before they’re stored in the database?

What you need is Polite Strings.  
[http://dppruby.com/dppsrubyplayground/show/Polite+Strings](http://dppruby.com/dppsrubyplayground/show/Polite+Strings)

Polite Strings is a module that you can add to your ActiveRecord  
classes. Polite Strings will make sure strings don’t overflow the  
column widths in the database (you can disable this function on a  
field-by-field basis). Polite Strings will optionally convert a  
column to lower case. Polite Strings will optionally convert bytes in  
your strings that have the high bit set to spaces (thus avoiding  
problems with older versions of PostgreSQL.)

---

<div class="post-metadata">

**Author:** ![dpitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a9adbd/32.png) [@dpitman](https://www.ruby-forum.com/u/dpitman)\
**Post date:** [July 28, 2006, 6:06am UTC](https://www.ruby-forum.com/t/polite-strings/100261/2 "2006-07-28T06:06:45Z")

</div>

David P. wrote:

> Do you have ActiveRecord classes that contain strings?
> 
> Do you sometimes put strings into those classes that are too wide for  
> the database column?
> 
> Is it really suboptimal when you get a SQL error when you .save the  
> object?
> 
> Are there string columns that you’d like to convert to lower case  
> before they’re stored in the database?

Do you like to ask rhetorical questions?
