New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make "class_name" option for polymorphic has_many
relation to STI required
#48925
Comments
+1 |
+1 i interest because i have the same problem on my projet ! But i don't want tell the class_name, i want a belongs_to or has_many on the Request and finds the right object on its own. |
@byroot do you have an idea ? :) |
It's definitely a bug; this should be using
I imagine I'll be happy with whatever behaviour that restores, though. "This might be pointing at an STI class and one of the STI children might have an association with the name you asked for, and you might know that all instances referencing this object are of that class" is clearly possible, but I don't foresee us encoding that level of detail into an error. If anyone's up for an easy PR, ☝🏻 plus a test would be welcome. |
@matthewd i seems to work :D |
@matthewd i will to try do an PR ;) |
[Fix #48925] fix "class_name" required for STI class
[Fix #48925] fix "class_name" required for STI class
Backported to |
I think we missed this but just incase anyone is looking for something to do 👀 |
Steps to reproduce
Models:
Then running in your console:
Raises you an error:
Expected behavior
To raise a detailed error, like "provide a
class_name
option to use joins on STI table with polymorphic, or make required optionclass_name
for polymorphic relation with STI", like:Actual behavior
Unknown error 🙂
System configuration
Rails version: 7.0.4
Ruby version: 3.1.1
The text was updated successfully, but these errors were encountered: