From b5962ea4bf61352e64040f5d04d3778c7288b98d Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 6 Jun 2014 19:17:58 +0800 Subject: [PATCH] Fix can_display for status ordering and hidden --- app/models/bulletin.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index 6d56988..7abca1f 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -34,6 +34,8 @@ class Bulletin before_destroy :destroy_email + scope :can_display, ->{where(:is_hidden=>false).any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}).order_by([:is_top, :desc])} + def update_user User.find(update_user_id) rescue nil end @@ -42,10 +44,6 @@ class Bulletin self.update_user_id = user.id end - def self.can_display() - self.any_of({:postdate.lt=>Time.now, :deadline.gt=>Time.now},{:postdate.lt=>Time.now, :deadline=>nil}) - end - def email_members MemberProfile.find(self.email_member_ids) rescue [] end