相关疑难解决方法(0)

如何在没有多个查询的情况下将Rails ActiveRecord链接到"where"子句?

我是一名PHP开发人员,学习Ruby on Rails的优点,我喜欢ActiveRecord,我注意到一些非常有趣的东西,这就是ActiveRecord方法检测方法链结束执行查询的方式.

@person = Person.where(name: 'Jason').where(age: 26)

# In my humble imagination I'd think that each where() executes a database query
# But in reality, it doesn't until the last method in the chain
Run Code Online (Sandbox Code Playgroud)

这个巫术是如何运作的?

activerecord ruby-on-rails

69
推荐指数
2
解决办法
4万
查看次数

标签 统计

activerecord ×1

ruby-on-rails ×1