Skip to content
a small ActiveRecord plugin that converts 'smart quotes' to their ASCII equivalents
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
MIT-LICENSE
README.rdoc
Rakefile
dumb_quotes.gemspec

README.rdoc

Dumb Quotes

For some reason I'm yet discern, I'm irrationally annoyed by “smart quotes”, the non-ASCII single and double quotes imposed on our databases by windows users.

There's no real reason to hate them, but I do. Maybe it's the extra few bytes they consume when encoded as UTF-8, or maybe it's the way they get converted to numeric entities in my XML exports. In any case, this ActiveRecord plugin makes the following changes to your model attributes before validation:

U+2018 (‘) -> '
U+2019 (’) -> '
U+02BC (ʼ) -> '
U+201C (“) -> "
U+201D (”) -> "
U+02EE (ˮ) -> "

Examples

class Product < ActiveRecord::Base
  dumb_quotes!
end

class Product < ActiveRecord::Base
  dumb_quotes!, :except => :title
end

class Product < ActiveRecord::Base
  dumb_quotes!, :only => :description
end

Installation

Option 1. Load the plugin as a gem

gem install dumb_quotes
add "config.gem 'dumb_quotes'" to your environment.rb

Option 2. Use the standard Rails plugin install (assuming Rails 2.1).

./script/plugin install git://github.com/yob/dumb_quotes.git

Caveats

The translation is done with raw bytes. If you happen to be using anything other than UTF-8 in your models, you're likely to munge data.

This also means it's almost certainly not ruby 1.9 compatible. Patches welcome.

Credits

This plugin is essentially a fork of the strip attributes plugin, released under the MIT License by Ryan McGeary.

github.com/rmm5t/strip_attributes

License

Copyright © 2007-2008 Ryan McGeary released under the MIT license Copyright © 2009 James Healy released under the MIT license

en.wikipedia.org/wiki/MIT_License

Something went wrong with that request. Please try again.