From ec2a209b68c1db0141cc8cd60420023d491ca8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Fri, 10 Apr 2015 19:19:16 +0200 Subject: [PATCH] Lazily initialize Contact proxy in service helper This prevents connecting to the database on rake assets:precompile, which fails in certain build environments. Running git blame on this and figuring out what in gods name this is for, is for another time. --- app/helpers/services_helper.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb index e164a6957..9fbe7bd29 100644 --- a/app/helpers/services_helper.rb +++ b/app/helpers/services_helper.rb @@ -1,6 +1,11 @@ module ServicesHelper - @@contact_proxy = Contact.new(:aspects => []) def contact_proxy(friend) - friend.contact || @@contact_proxy.dup.tap{|c| c.person = friend.person} + friend.contact || contact_proxy_template.dup.tap {|c| c.person = friend.person } + end + + private + + def contact_proxy_template + @@contact_proxy ||= Contact.new(:aspects => []) end end