Rails范围 - 完全匹配的位置

时间:2015-11-16 08:48:00

标签: ruby-on-rails postgresql ruby-on-rails-3 activerecord

是否可以使用where IN (?)查询在Rails中创建范围,这将检查完全匹配?

例如:

Post.joins(:tags).where('tags.id IN (?)', [1, 2, 3, 4])

会找到包含代码1, 21, 2, 31, 2, 3, 4的帖子。但是应该只找到包含1, 2, 3, 4标签的帖子。

2 个答案:

答案 0 :(得分:1)

要获得匹配monsterHealth = 20 playerHealth = 50 while monsterHealth > 0: print ("The monster attacks you dealing 10 damage") global playerHealth playerHealth = playerHealth - 10 playerDecision = input("Would you like to stay and fight? y/n") if playerDecision == y: print ("You attack the monster and do 5 damage") if playerDecision == n: print("You run away with your tail between your legs.") break if playerHealth <= 0: print ("You died......") break if monsterHealth <= 0: print ("You defeated the monster!") break 子句中所有值的想法,你必须这样做:

setInterval

我希望这对你有所帮助。

答案 1 :(得分:0)

这应该在pgsql数据库中工作。

from zeep import Client
from zeep import xsd
from zeep.plugins import HistoryPlugin
import lxml.etree as etree

wsdl = 'http://localhost/services/Assets?wsdl'
history = HistoryPlugin()
client = Client(wsdl, plugins=[history])
credentialType = client.get_type('ns0:UserCredentialsType')
credentials = credentialType(Username='user', Password='passwortd')
credentialTest = { 'UserCredentials': { 'Username':'user', 'Password':'password'}} 
param = client.get_type('ns0:GetChildrenType')
params = param(InterplayURI='uri') 
header = xsd.ComplexType([
    xsd.Sequence([
        xsd.Element('Username', xsd.String()),
        xsd.Element('Password', xsd.String())
        ])
    ])
header_value = header(Username='user', Password='password')
response = client.create_message(client.service, 'GetChildren', params, _soapheaders=[credentials])
request = etree.tostring(response)
serverResponse = client.service.GetChildren(request)
print(request)
print(serverResponse)