diff --git a/app/helpers/status_messages_helper.rb b/app/helpers/status_messages_helper.rb index 4c764595fb1d66d1b04853e2ec49e4ab8ac2e4e7..147486830111dd1b662dcdab9de859c97b519b10 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 20add29c542f8ea5c99852c4fef6854d4fc4c27a..87b3dea7894138c389c108c79957323bbf6aaeac 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 c1c10fe68c1086e0327c3ddd04413eb10734f1c6..9653e463d719ae6b9a6d68173efc37a04070c9d3 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