0.0
No commit activity in last 3 years
No release in over 3 years
The gem helps you by deleting spaces, special characters or replacing accents in the fields you need.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Preformatter

Sometimes you have to create some naggy before_validation methods to format strings the way you need to. I find this to be a cleaner way to do it and less painful to maintain.

The gem helps you by deleting spaces, special characters or replacing accents in the fields you need.

For now the gem is usable only in Rails 2.3.x projects, in the near future it will be updated for Rails 3.

This gem was built with code from the EMR Bear project PrescriptionRex


Install

gem install preformatter

In the environment.rb you must configure the gem as following:

config.gem 'preformatter'

Usage

All the code below goes directly into the model you want to use the preformatting, the formatting will be done before validation.

Deleting white spaces

no_space_in 	:field1, :field2, :field3

If the user input is for instance ‘some words with spaces’ it will be transformed into ‘somewordswithspaces’

Replacing accents

no_accents_in	:field1, :field2, :field3

If the user input is ‘Sómé wórds wíth áccénts’ it will be transformed into ‘Some words with accents’

Replacing special characters

This method works a little different becouse you have to provide a string with all the special characters you dont want in an attribute.

no_special_characters '(){}-', :in => [:phone, :fax, :id]

If the user input is ‘(81)-83987832 {345}’ it will be transformed into ‘8183987832’


Copyright

Copyright © 2010 Innku, PrescriptionRex. See LICENSE for details.