Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

Modify the ActiveResource::Associations module's has_many definition to invoke Base.all, rather than Base.find(:all) in order to utilize the deferred record fetching introduced in #422.

class Person < ActiveResource::Base
  self.site = "https://example.com"

  has_many :people
end

person = Person.find(1)                 # => GET /people/1.json
person.people                           # => GET /people.json?person_id=1
person.people.where(name: "Related")    # => GET /people.json?person_id=1&name=Related

@seanpdoyle seanpdoyle force-pushed the has-many-where-chain branch from 3e9aae6 to a868196 Compare October 28, 2025 03:39
Modify the `ActiveResource::Associations` module's `has_many` definition
to invoke `Base.where`, rather than `Base.find(:all)` in order to
utilize the deferred record fetching introduced in [rails#422][].

```ruby
class Person < ActiveResource::Base
  self.site = "https://example.com"

  has_many :people
end

person = Person.find(1)                 # => GET /people/1.json
person.people                           # => GET /people.json?person_id=1
person.people.where(name: "Related")    # => GET /people.json?person_id=1&name=Related
```

[rails#422]: rails#422
@guilleiguaran guilleiguaran merged commit 4fffccc into rails:main Nov 19, 2025
19 checks passed
@seanpdoyle seanpdoyle deleted the has-many-where-chain branch November 19, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants