Skip to content

Conversation

@cgunther
Copy link
Contributor

@cgunther cgunther commented Mar 7, 2025

Given a load declaration like:

load_resource :order
load_resource through: :address, through_association: :custom_address, singleton: true

The :through_assocation option wasn't being respected in the :singleton branch, thus falling back to calling find, but odds are you wouldn't have an ID given it was a singleton, thus leading to an error.

Now it uses the :through_association before falling back to the name.

Fixes #604.

@cgunther cgunther force-pushed the through-association-singleton branch from aca0509 to aad91da Compare March 7, 2025 02:43
Given a load declaration like:
```ruby
load_resource :order
load_resource through: :address, through_association: :custom_address, singleton: true
```

The `:through_assocation` option wasn't being respected in the
`:singleton` branch, thus falling back to calling `find`, but odds are
you wouldn't have an ID given it was a singleton, thus leading to an
error.

Now it uses the `:through_association` before falling back to the
`name`.

Fixes CanCanCommunity#604.
@cgunther cgunther force-pushed the through-association-singleton branch from aad91da to 208a24f Compare March 7, 2025 02:48
@cgunther
Copy link
Contributor Author

cgunther commented Mar 7, 2025

CI seems to be failing against ActiveRecord main due to bumping to sqlite3 v2 in Rails 8.0 but the gemfile is using v1.7:
rails/rails@2976d37

It's also failing against ActiveRecord v6.0, v6.1, and v7.0 due to a change in concurrent-ruby where it stopped requiring the logger gem, but ActiveSupport was relying on it to require logger. This was fixed in v7.1:
rails/rails#49372
and a PR was merged to branch 7-0-stable and 6-1-stable, but there hasn't been a release yet:
rails/rails#54264
rails/rails#54621

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.

:through_association and :singleton

1 participant