Skip to content

Commit aa17c5a

Browse files
author
Joost Hietbrink
committed
Version 0.2.1
1 parent afbf889 commit aa17c5a

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

README.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ In your model add:
2727

2828
class SomeModel < ActiveRecord::Base
2929

30-
# Normalizes the attribute itself before validation
30+
# Normalizes the attribute itself before validation
3131
phony_normalize :phone_number, :default_country_code => 'US'
3232

3333
# Normalizes attribute before validation and saves into other attribute
34-
phony_normalize :phone_number, :as => :phone_number_normalized_version, :default_country_code => 'US'
34+
phony_normalize :phone_number, :as => :phone_number_normalized_version, :default_country_code => 'US'
3535

3636
# Creates method normalized_fax_number that returns the normalized version of fax_number
3737
phony_normalized_method :fax_number
@@ -78,11 +78,11 @@ In your views use:
7878

7979
<%= "311012341234".phony_formatted(:format => :international, :spaces => '-') %>
8080
<%= "+31-10-12341234".phony_formatted(:format => :international, :spaces => '-') %>
81-
<%= "+31(0)1012341234".phony_formatted(:format => :international, :spaces => '-') %>
81+
<%= "+31(0)1012341234".phony_formatted(:format => :international, :spaces => '-') %>
8282

8383
To first normalize the String to a certain country use:
8484

85-
<%= "010-12341234".phony_formatted(normalize => :NL, :format => :international, :spaces => '-') %>
85+
<%= "010-12341234".phony_formatted(normalize => :NL, :format => :international, :spaces => '-') %>
8686

8787
You can also use the bang method (phony_formatted!):
8888

@@ -98,28 +98,31 @@ Say you want to find a record by a phone number. Best is to normalize user input
9898

9999
## Changelog
100100

101+
0.2.1
102+
* Better error handling by @k4nar
103+
101104
0.1.12
102105
* Further loosened gemspec dependencies.
103106

104107
0.1.11
105-
* Better gemspec dependency versions by rjhaveri.
108+
* Better gemspec dependency versions by @rjhaveri.
106109

107110
0.1.10
108111
* Changes from henning-koch.
109112
* Some pending fixes.
110113

111114
0.1.8
112-
* Improved validation methods by ddidier.
115+
* Improved validation methods by @ddidier.
113116

114117
0.1.6
115118
* Added :as option to phony_normalize.
116119

117120
0.1.5
118-
* some tests and a helper method by ddidier.
121+
* some tests and a helper method by @ddidier.
119122

120123
0.1.2
121-
* Using countries gem as suggested by brutuscat.
122-
* Fixes bugs mentioned by ddidier.
124+
* Using countries gem as suggested by @brutuscat.
125+
* Fixes bugs mentioned by @ddidier.
123126

124127
0.1.0
125128
* Added specs.

lib/phony_rails.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def set_phony_normalized_numbers(attributes, options = {})
4949
options[:country_code] ||= self.country_code if self.respond_to?(:country_code)
5050
attributes.each do |attribute|
5151
attribute_name = options[:as] || attribute
52-
raise RuntimeError, "No attribute #{attribute_name} found on #{self.class.name} (PhonyRails)" if not self.respond_to?(attribute_name)
52+
raise RuntimeError, "No attribute #{attribute_name} found on #{self.class.name} (PhonyRails)" if not self.attribute_method?(attribute_name)
5353
write_attribute(attribute_name, PhonyRails.normalize_number(read_attribute(attribute), options))
5454
end
5555
end

lib/phony_rails/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module PhonyRails
2-
VERSION = "0.2.0"
2+
VERSION = "0.2.1"
33
end

0 commit comments

Comments
 (0)