简体   繁体   中英

Where Clause with OR in Rails

How do I write a where clause where I have a where argument that can take multiple options. For example,

User.where(name: "Jason" OR name: "Bob")

Although I know that isn't the correct syntax, what is?

虽然我没有要检查的控制台,但我很确定它是:

User.where(name: ["Jason", "Bob"])

I'm always late to the party...

friends = User.where(:name => ["Jason", "Bob"])

(Rails 4.0.0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM