From 8d865859284e90f8050661b36835604d448d687e Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Mon, 17 Jan 2011 18:22:54 -0800 Subject: [PATCH] profile spec passes --- app/models/profile.rb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index f0b5865e2..47d709e84 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -56,17 +56,29 @@ class Profile < ActiveRecord::Base def image_url= url return image_url if url == '' - super(url) + if url.nil? || url.match(/^https?:\/\//) + super(url) + else + super(absolutify_local_url(url)) + end end def image_url_small= url return image_url if url == '' - super(url) + if url.nil? || url.match(/^https?:\/\//) + super(url) + else + super(absolutify_local_url(url)) + end end def image_url_medium= url return image_url if url == '' - super(url) + if url.nil? || url.match(/^https?:\/\//) + super(url) + else + super(absolutify_local_url(url)) + end end def date= params @@ -86,4 +98,10 @@ class Profile < ActiveRecord::Base self.last_name.strip! if self.last_name end + private + def absolutify_local_url url + pod_url = AppConfig[:pod_url].dup + pod_url.chop! if AppConfig[:pod_url][-1,1] == '/' + "#{pod_url}#{url}" + end end