No commit activity in last 3 years
No release in over 3 years
Sanitise attributes to avoid invalid byte sequence argument errors
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
 Project Readme

Utf8AttributeSanitiser

Sanitise attributes to avoid invalid byte sequence argument errors

Installation

Add this line to your application's Gemfile:

gem 'utf8_attribute_sanitiser'

And then execute:

$ bundle

Or install it yourself as:

$ gem install utf8_attribute_sanitiser

Usage

In your model add utf8_attribute_sanitiser, specyfing list of attribute names to sanitise

class User < ActiveRecord::Base
  utf8_attribute_sanitiser :name, :address
end

Default cleaning method is utf8mb4only and it only affects 4 byte characters

You can use aggressive clean method that strips out all invalud utf8 characters like

class User < ActiveRecord::Base
  utf8_attribute_sanitiser :name, :address, method: :aggressive
end

Running tests

$ rspec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tomdracz/utf8_attribute_sanitiser.

License

The gem is available as open source under the terms of the MIT License.