def teachers_on(time) condition = (time && time.is_a?(Time) ? "deleted_at is NULL OR deleted_at > '#{time.strftime("%Y-%m-%d %H:%M:%S")}' " : "") self.teachers.find(:all, :with_deleted => true, :conditions => condition) end