From bbe46baab77c2b193d796ee6935d8c8fe974c2b9 Mon Sep 17 00:00:00 2001 From: Lee Lawlor Date: Mon, 27 Oct 2014 12:52:15 -0400 Subject: [PATCH] fix user's website links --- app/models/user.rb | 7 +++++++ app/views/users/profile.html.erb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index e051000..804a831 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -56,6 +56,13 @@ class User < ActiveRecord::Base cattr_reader :per_page @@per_page = 50 + # display the user's website correctly + def display_website + output = self.website + output = "http://#{website}" if output.present? && output.index('http') != 0 + return output + end + # get the user's time zone or UTC time def time_zone_or_utc; time_zone || 'UTC'; end diff --git a/app/views/users/profile.html.erb b/app/views/users/profile.html.erb index 995e9c0..cff7293 100644 --- a/app/views/users/profile.html.erb +++ b/app/views/users/profile.html.erb @@ -8,7 +8,7 @@

<%= t(:profile_for) %> <%= @user.login %>

<%= t(:member_since) %> <%= @user.created_at.strftime('%B %-d, %Y') %>

- <%= t(:profile_website) %>: <%= link_to @user.website, @user.website %> + <%= t(:profile_website) %>: <%= link_to @user.website, @user.display_website, target: '_blank' %>

<%= t(:profile_bio) %>: <%= @user.bio %>