diff --git a/app/helpers/status_messages_helper.rb b/app/helpers/status_messages_helper.rb index 4c764595f..147486830 100644 --- a/app/helpers/status_messages_helper.rb +++ b/app/helpers/status_messages_helper.rb @@ -1,2 +1,10 @@ module StatusMessagesHelper + def my_latest_message + message = StatusMessage.my_newest + unless message.nil? + return message.message + " " + time_ago_in_words(message.created_at) + "ago." + else + return "No message to display." + end + end end diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 20add29c5..87b3dea78 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -15,7 +15,7 @@ class StatusMessage before_create :set_default_owner def self.newest(owner_email) - StatusMessage.last(:conditions => {:owner => owner_email}) + message = StatusMessage.last(:conditions => {:owner => owner_email}) end def self.my_newest diff --git a/app/views/status_messages/index.html.haml b/app/views/status_messages/index.html.haml index c1c10fe68..9653e463d 100644 --- a/app/views/status_messages/index.html.haml +++ b/app/views/status_messages/index.html.haml @@ -1,7 +1,7 @@ - title "Home" %h3 Your latest message -%h2= "#{StatusMessage.my_newest.message} #{time_ago_in_words(StatusMessage.my_newest.created_at)} ago" +%h2= my_latest_message %br %br