From c1ab2848df8155a599d73fb9726cc4a2d5b6b642 Mon Sep 17 00:00:00 2001 From: Rick Barrette Date: Wed, 11 May 2016 06:30:18 -0400 Subject: [PATCH] Update customer.rb --- app/models/customer.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/models/customer.rb b/app/models/customer.rb index 1cdff70..92c0e74 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -20,7 +20,7 @@ class Customer < ActiveRecord::Base attr_accessible :name validates_presence_of :id, :name - after_find :get_details, :unless + after_initialize :get_details self.primary_key = :id @@ -137,11 +137,9 @@ class Customer < ActiveRecord::Base # if the method's name ends with '=' if name[-1, 1] == "=" method_name = name[0..-2] - puts "Setting '#{method_name}' to '#{value}'" @details[method_name] = value push else - puts "Getting '#{name}'" begin return @details[name] rescue @@ -172,12 +170,9 @@ class Customer < ActiveRecord::Base # init details def get_details - t= Thread.new { - if self.id - @details = get_customer(self.id) - end - } - t.join + if self.id + @details = get_customer(self.id) + end end # update's the customers name if updated