summaryrefslogtreecommitdiff
path: root/billing/app/models/customer.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-02 12:12:45 +0200
committerAzul <azul@leap.se>2013-07-17 10:47:14 +0200
commit5589ef858a19f1c46e7e8aa5b364914a5f14352a (patch)
tree58f3f8350a7594e467f9e497bd0836ed55cad755 /billing/app/models/customer.rb
parent82f58b469fa48ca54cbc283685021a2502cf1dd1 (diff)
billing: fix issue with customer.braintree_customer
The default CouchRest Model belongs_to does not respect the class option. So we need to write our own getter method.
Diffstat (limited to 'billing/app/models/customer.rb')
-rw-r--r--billing/app/models/customer.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/billing/app/models/customer.rb b/billing/app/models/customer.rb
index 4788118..747f17f 100644
--- a/billing/app/models/customer.rb
+++ b/billing/app/models/customer.rb
@@ -5,7 +5,12 @@ class Customer < CouchRest::Model::Base
use_database "customers"
belongs_to :user
- belongs_to :braintree_customer, class: Braintree::Customer
+ belongs_to :braintree_customer
+
+ # Braintree::Customer - stored on braintrees servers - we only have the id.
+ def braintree_customer
+ @braintree_customer ||= Braintree::Customer.find(braintree_customer_id)
+ end
validates :user, presence: true