Rails where子句具有关联和多个条件

时间:2017-02-23 04:25:32

标签: ruby-on-rails activerecord

所以我有以下select声明:

requests = Request.select { |x| (x.name_rel == user || x.customer_rel == user || x.users.include?(user))

基本上,我试图获得requests user requests belongs_to :name_rel, :class_name => "User", :foreign_key => 'name_id' belongs_to :customer_rel, :class_name => "User", :foreign_key => 'customer_id' has_and_belongs_to_many :users select的所有where,其中> time1.to_i == time2.to_datetime.to_i => true 具有以下关系:

import os, sys
import random
import pygame
from pygame.locals import *


My_red_color = (255, 0, 0)
My_blue_color = (0, 0, 255)
My_green_color = (0, 255, 0)
My_yellow_color = (255, 255, 0)
My_black_color = (0,0,0)
My_white_color = (255,255,255)

pygame.init()
APPLICATION_x_size = 800
APPLICATION_y_size = 800
screen = pygame.display.set_mode((APPLICATION_x_size, APPLICATION_y_size))

我理解x=200 y=400 pygame.display.set_caption('Piano') pygame.mouse.set_visible(True) #pygame.mouse.set_visible(False) green_square= pygame.Surface(screen.get_size()) green_square.fill((0, 255, 0)) screen.blit(green_square, (0, 0)) Weeee = True pygame.draw.rect(screen, My_white_color, (30,100,100,200)) pygame.draw.rect(screen, My_white_color, (132,100,100,200)) pygame.draw.rect(screen, My_white_color, (234,100,100,200)) pygame.draw.rect(screen, My_white_color, (336,100,100,200)) pygame.draw.rect(screen, My_white_color, (438,100,100,200)) pygame.draw.rect(screen, My_white_color, (540,100,100,200)) pygame.draw.rect(screen, My_white_color, (642,100,100,200)) pygame.draw.rect(screen, My_black_color, (81,50,100,200)) pygame.draw.rect(screen, My_black_color, (183,50,100,200)) pygame.draw.rect(screen, My_black_color, (387,50,100,200)) pygame.draw.rect(screen, My_black_color, (489,50,100,200)) pygame.draw.rect(screen, My_black_color, (591,50,100,200)) b=screen.blit(myImg, (x,y)) pygame.display.flip() while Weeee : for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_a: print("C") pygame.mixer.music.load('E:\성빈\고등학교\과학전람회\pygame piano\pygame piano\sound1.mp3') pygame.mixer.music.play(1,0) if event.key == pygame.K_s: print("D") pygame.mixer.music.load('E:\성빈\고등학교\과학전람회\pygame piano\pygame piano\sound2.mp3') pygame.mixer.music.play(1,0) if event.key == pygame.K_d: print("E") pygame.mixer.music.load('E:\성빈\고등학교\과학전람회\pygame piano\pygame piano\sound3.mp3') pygame.mixer.music.play(1,0) if event.key == pygame.K_f: print("F") pygame.mixer.music.load('E:\성빈\고등학교\과학전람회\pygame piano\pygame piano\sound4.mp3') pygame.mixer.music.play(1,0) if event.key == pygame.K_g: print("G") pygame.mixer.music.load('E:\성빈\고등학교\과학전람회\pygame piano\pygame piano\sound5.mp3') pygame.mixer.music.play(1,0) if event.key == pygame.K_h: print("A") pygame.mixer.music.load('E:\성빈\고등학교\과학전람회\pygame piano\pygame piano\sound6.mp3') pygame.mixer.music.play(1,0) if event.key == pygame.K_j: print("B") pygame.mixer.music.load('E:\성빈\고등학교\과학전람회\pygame piano\pygame piano\sound7.mp3') pygame.mixer.music.play(1,0) if event.type == MOUSEBUTTONDOWN : if event.button==1 : print("Setting Code") my_code=pygame.key.get_pressed() print("My code is" + str(my_code)) if event.button == 3 : print("Type your Code") code_try=pygame.key.get_pressed() if code_try==my_code : print("Done") else : print("You've typed wrong code") 是一种非常糟糕的方法,但我不确定如何使{{1}}能够处理如此复杂的操作。有人能指出我正确的方向吗?

1 个答案:

答案 0 :(得分:3)

您可以在以下情况下执行此操作

Sub Filter_Change()

Dim WS As Worksheet: Set WS = ActiveWorkbook.Worksheets("Main")
Dim PT1 As PivotTable: Set PT1 = WS.PivotTables("IncTrend")
Dim PF1 As PivotField: Set PF1 = PT1.PivotFields("[Inc Open].[Service].[Service]")
Dim Choice As String: Choice = Worksheets("Main").Range("A2").Value

With PF1
    .ClearAllFilters
    .CurrentPage = Choice
    '.PivotFilters.Add Type:=xlCaptionEquals, Value1:=Choice
End With
End Sub