-
Notifications
You must be signed in to change notification settings - Fork 12
association with a class_name parameter #7
Copy link
Copy link
Open
Description
Hi,
First of all, great gem! This is exactly what I needed for my Rails app.
Unfortunately, I had an issue with associations that have a different name than their class, for reversing relationships with two foreign keys from the same model. Here's what it looks like:
has_many :relationships, foreign_key: "subject_id", dependent: :delete_all
has_many :reverse_relationships, class_name: "Relationship",
foreign_key: "target_id",
dependent: :delete_allI think it's a problem with the way you access the model class. As far as I know, this is what the gem does:
sub_model_class = :association_name.to_s.classify.constantizeSince ReverseRelationship is not a class, this gives me this error when using recuse_delete: NameError: uninitialized constant ReverseRelationship
It'd be great if you could have this working for associations that use class_name as well.
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels