aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKir2011-12-14 19:00:37 +0400
committerKir2011-12-14 19:00:37 +0400
commit35e185b02d869bd69cd2bec65d4058e967f97aa5 (patch)
tree29a96c901c96aa84a31894abab1dd641239bec7e /app
parent50a241e922ff4b58b3fc3e52162f4e199e1fae3d (diff)
downloadinboxes-35e185b02d869bd69cd2bec65d4058e967f97aa5.tar.bz2
Refactoring
Diffstat (limited to 'app')
-rw-r--r--app/models/discussion.rb2
-rw-r--r--app/views/inboxes/discussions/index.html.haml5
2 files changed, 5 insertions, 2 deletions
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index 7230538..a5b12ca 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -85,7 +85,7 @@ class Discussion < ActiveRecord::Base
end
# return amount of unreaded messages for current discussion
- def count_unread_mess(user)
+ def unread_messages_count_for(user)
speaker = find_speaker_by_user(user)
messages.where("updated_at > ?", speaker.updated_at ).where("user_id != ?", speaker.id ).count
end
diff --git a/app/views/inboxes/discussions/index.html.haml b/app/views/inboxes/discussions/index.html.haml
index 3d47a59..433e929 100644
--- a/app/views/inboxes/discussions/index.html.haml
+++ b/app/views/inboxes/discussions/index.html.haml
@@ -11,7 +11,10 @@
%td
= link_to discussion.users.collect{|u| u[Inboxes::config.user_name]}.join(', '), discussion
%td
- = discussion.unread_for?(current_user) ? (discussion.count_unread_mess(current_user).to_s + ' сообщение') : "No"
+ - if discussion.unread_for?(current_user)
+ = pluralize(discussion.unread_messages_count_for(current_user), "message")
+ - else
+ No unread messages
%p
= link_to "Create new", new_discussion_path