fix visibility criterion for dmails

This commit is contained in:
albert
2012-01-15 13:28:00 -05:00
parent 914d2d5b4e
commit 483da433aa

View File

@@ -17,7 +17,7 @@ class Dmail < ActiveRecord::Base
scope :deleted, where(["is_deleted = ?", true])
scope :search_message, lambda {|query| where(["message_index @@ plainto_tsquery(?)", query])}
scope :unread, where("is_read = false and is_deleted = false")
scope :visible, lambda {where("(to_id = ? or from_id = ?)", CurrentUser.id, CurrentUser.id)}
scope :visible, lambda {where("owner_id = ?", CurrentUser.id)}
scope :to_name_matches, lambda {|name| where("to_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)}
scope :from_name_matches, lambda {|name| where("from_id = (select _.id from users _ where lower(_.name) = ?)", name.downcase)}
search_method :to_name_matches, :from_name_matches