hyperstack-org / hyperstack-org/hyperstack
foreign key in has_many broken
- Dominant language
- JavaScript
- Stars
- 538
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
for example:
```ruby
belongs_to :duplicate_of, class_name: 'Report', required: false
has_many :duplicates, class_name: 'Report', foreign_key: 'duplicate_of_id'
```
breaks because of this code in the `ClassMethods#_react_param_conversion` method:
```ruby
assoc = associations.detect do |poly_assoc|
if key == poly_assoc.polymorphic_type_attribute
model_name = value
already_processed_keys << poly_assoc.association_foreign_key
elsif key == poly_assoc.association_foreign_key
model_id = value
already_processed_keys << poly_assoc.polymorphic_type_attribute
end
end
```
it is treating every relationship with a foreign key as a polymorphic relationship.
Clearly a regression when polymorphic was added
Contributor guide
Assessment
This issue has not been assessed yet.