From 4e03c97832d1e35737af3ced026541c3a8e4abac Mon Sep 17 00:00:00 2001 From: Tair Assimov Date: Sat, 4 Oct 2008 13:26:58 +0300 Subject: [PATCH] Adding last_activity_at on public profile (needs timezone handling) Changing to rails 2.1.1 --- app/controllers/application.rb | 1 + app/views/profiles/_bio.html.erb | 3 ++- config/environment.rb | 2 +- db/migrate/006_add_profile_last_activity_at.rb | 9 +++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/006_add_profile_last_activity_at.rb diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 38524c9..346a110 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -23,6 +23,7 @@ def pagination_defaults def set_profile @p = @u.profile if @u && @u.profile + @p.update_attribute :last_activity_at, Time.now if @p end diff --git a/app/views/profiles/_bio.html.erb b/app/views/profiles/_bio.html.erb index bbb566e..2b878ed 100644 --- a/app/views/profiles/_bio.html.erb +++ b/app/views/profiles/_bio.html.erb @@ -4,7 +4,8 @@ profile ||= @profile
<%= icon profile, :big %>
-

<%= h profile.f %>

+

<%= h profile.f %>

+ <% unless profile.last_activity_at.blank? %>Last seen <%= time_ago_in_words profile.last_activity_at %> ago<% end %>

<%= location_link profile %>

<% unless profile.about_me.blank? %>
About: <%= sanitize(textilize(profile.about_me)) %>
<% end %> <% unless profile.website.blank? %>
Website: <%= link_to h(profile.website), h(profile.website) %>
<% end %> diff --git a/config/environment.rb b/config/environment.rb index 3b9f103..6fd1691 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION +RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') diff --git a/db/migrate/006_add_profile_last_activity_at.rb b/db/migrate/006_add_profile_last_activity_at.rb new file mode 100644 index 0000000..2118917 --- /dev/null +++ b/db/migrate/006_add_profile_last_activity_at.rb @@ -0,0 +1,9 @@ +class AddProfileLastActivityAt < ActiveRecord::Migration + def self.up + add_column :profiles, :last_activity_at, :datetime + end + + def self.down + remove_column :last_activity_at + end +end