lib/preformatter.rb in preformatter-0.2.0 vs lib/preformatter.rb in preformatter-0.3.0
- old
+ new
@@ -17,10 +17,12 @@
def no_accents_in(*args)
args.each do |field|
before_validation do |record|
attribute = record.send("#{field.to_s}")
- replace = {'á' => 'a','é' => 'e','í' => 'i','ó' => 'o','ú' => 'u'}
+ replace = {'á' => 'a','é' => 'e','í' => 'i','ó' => 'o','ú' => 'u',
+ 'ñ' => 'n', 'Ñ' => 'N',
+ 'Á' => 'A' , 'É' => 'E', 'Í' => 'I', 'Ó' => 'O','Ú' => 'U'}
unless attribute.nil?
attribute.gsub!(/[#{replace.keys.join('|')}]/).each do |c|
replace[c]
end
end
\ No newline at end of file