This commit is contained in:
albert
2012-01-14 14:58:33 -05:00
parent 6d8dd7a5f2
commit ec22f95136
3 changed files with 6 additions and 2 deletions

View File

@@ -18,6 +18,9 @@ class Dmail < ActiveRecord::Base
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 :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
module AddressMethods
def to_name

View File

@@ -43,6 +43,7 @@ class User < ActiveRecord::Base
scope :admins, where("is_admin = TRUE")
scope :with_email, lambda {|email| email.blank? ? where("FALSE") : where(["email = ?", email])}
scope :find_for_password_reset, lambda {|name, email| email.blank? ? where("FALSE") : where(["name = ? AND email = ?", name, email])}
search_method :named
module BanMethods
def validate_ip_addr_is_not_banned

View File

@@ -5,8 +5,8 @@
<%= hidden_field_tag :folder, params[:folder] %>
<%= f.input :title_contains, :required => false, :label => "Title" %>
<%= f.input :body_contains, :required => false, :label => "Body" %>
<%= f.input :to_name_equals, :required => false, :label => "To" %>
<%= f.input :from_name_equals, :required => false, :label => "From" %>
<%= f.input :to_name_matches, :required => false, :label => "To" %>
<%= f.input :from_name_matches, :required => false, :label => "From" %>
<%= f.button :submit, "Search" %>
<% end %>
</div>