This commit is contained in:
albert
2012-01-06 19:24:20 -05:00
parent 4135fb2f8c
commit 37e2d36e8b
2 changed files with 2 additions and 2 deletions

View File

@@ -14,9 +14,8 @@ class DmailsController < ApplicationController
end
def index
@search = Dmail.search(params[:search])
@search = Dmail.visible.search(params[:search])
@dmails = @search.paginate(params[:page]).order("dmails.created_at desc")
@dmails.each {|x| check_privilege(x)}
respond_with(@dmails)
end

View File

@@ -17,6 +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)}
module AddressMethods
def to_name