Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个Post具有 2 个属性的模型:
Post
attr1和attr2
attr1
attr2
我想检查任一属性是否定义了值或与“nil”不同。
我该怎么做?
谢谢!
这个问题的解决方案是下一个查询:
Post.any_of({ :attr1.ne => nil }, { :attr2.ne => nil})
非常感谢你!。问候!