cheddargetter_client_rails 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +37 -20
- data/VERSION +1 -1
- data/cheddargetter_client_rails.gemspec +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -7,32 +7,48 @@ Much of the heavy lifting with the api itself is done through the cheddargetter_
|
|
7
7
|
|
8
8
|
=== In the model
|
9
9
|
|
10
|
-
|
11
|
-
cheddargetter_billable_on :customer_code, :shared_columns => {
|
12
|
-
:email => :email,
|
13
|
-
:firstName => :first_name,
|
14
|
-
:lastName => :last_name,
|
15
|
-
:planCode => :plan_code
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
The first argument is the unique identifier column that CheddarGetter uses for the customers' customerCode.
|
20
|
-
It can be any column as long as it is unique.
|
10
|
+
It can be very simple if you go with the default columns, ie:
|
21
11
|
|
22
|
-
|
23
|
-
|
12
|
+
:customerCode => :id
|
13
|
+
:email => :email,
|
14
|
+
:firstName => :first_name,
|
15
|
+
:lastName => :last_name,
|
16
|
+
:planCode => :plan_code
|
24
17
|
|
25
|
-
|
18
|
+
Then the declaration in the model is simply:
|
26
19
|
|
27
20
|
class User < ActiveRecord::Base
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
has_subscription
|
22
|
+
end
|
23
|
+
|
24
|
+
These are the only required columns however you can change their names locally very easily.
|
25
|
+
|
26
|
+
class User < ActiveRecord::Base
|
27
|
+
has_subscription :customerCode => :customer_code,
|
28
|
+
:firstName => :name
|
29
|
+
:lastName => :l_name
|
30
|
+
:email => :business_email
|
31
|
+
:planCode => "FREE_PLAN"
|
32
|
+
|
34
33
|
end
|
35
34
|
|
35
|
+
Note that the plan code can also take a string.
|
36
|
+
|
37
|
+
The has_subscription will also takes additional key/values of items that appear both in your records for the user and CheddarGetter's records. For instance zip code is a common one. Here are others:
|
38
|
+
|
39
|
+
:ccFirstName,
|
40
|
+
:ccLastName,
|
41
|
+
:ccExpiration,
|
42
|
+
:ccNumber,
|
43
|
+
:ccCountry,
|
44
|
+
:ccAddress,
|
45
|
+
:ccCity,
|
46
|
+
:ccState,
|
47
|
+
:company,
|
48
|
+
:zip
|
49
|
+
|
50
|
+
When the save is called on the subscription object or create is called on the user it grabs all shared attributes from your ActiveRecord record.
|
51
|
+
|
36
52
|
=== In the controller
|
37
53
|
|
38
54
|
Make sure the subscription is always set on the user as some data may only exist there.
|
@@ -121,6 +137,7 @@ Do something like this, if it is a user form use fields_for @user.subscription i
|
|
121
137
|
<dd>
|
122
138
|
<%= subscription.text_field :ccCountry, :autocomplete => 'off' %>
|
123
139
|
</dd>
|
140
|
+
</dt
|
124
141
|
</fieldset>
|
125
142
|
<% end %>
|
126
143
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.15
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheddargetter_client_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 15
|
10
|
+
version: 0.1.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brent Wooden
|