wvanbergen/activerecord-databasevalidations — pull request #7 by wvanbergen (2014-11-26 20:55:22+00:00)
Title: Add support for truncating strings (like MySQL in non-strict mode)

This adds string truncating that is compatible with MySQL in non-strict mode.

Why? Because sometimes this is the desired behavior. Example:
``` ruby
Order.create!(
price: params[price],
referring_site: request.referrer
)
```

In this case I don't want the order to be created if the price field is out of bounds, but if the referring_site is, I rather have it truncate that field instead of the order failing completely.

``` ruby
class Order < ActiveRecord::Base
include ActiveRecord::DatabaseValidations::StringTruncator

before_validation truncate_string(:referring_site)

validates :price, database_constraints: :range
validates :referring_site, database_constraints: :size
end
```

This way we can safely implement this behavior so we can eventually turn on strict mode.

@byroot @fw42 @jduff for review.