W jaki sposób Rails ActiveRecord łańcuchuje „gdzie” klauzule bez wielu zapytań?
Jestem programistą PHP uczącym się niesamowitości Ruby on Rails, kocham ActiveRecord i zauważyłem coś naprawdę interesującego, w jaki sposób metody ActiveRecord wykrywają łańcuch końca metody do wykonania zapytania.
@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
Jak działa ta magia?