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
ActiveRecord::DangerousAttributeError: object_id is defined by Active Record #50160
Comments
I think the action here is to rename the column in the app to something else. |
Using the |
Ah, ok. I see Still not sure this is a good idea, but |
Fixes rails#50160 The `object_id` name may be used by polymorphic relations where `object` is the best name, like `notification.object`. In that case two columns are created: `object_id` and `object_type`. Update tests and comments to reference `__id__` instead of `object_id` for consistency.
Fixes rails#50160 The `object_id` name may be used by polymorphic relations where `object` is the best name, like `notification.object`. In that case two columns are created: `object_id` and `object_type`. Update tests and comments to reference `__id__` instead of `object_id` for consistency.
Fixes rails#50160 The `object_id` name may be used by polymorphic relations where `object` is the best name, like `notification.object`. In that case two columns are created: `object_id` and `object_type`. Update tests and comments to reference `__id__` instead of `object_id` for consistency.
I don't mind allowing it again, but we should find some way to test that active record itself doesn't rely on it :) |
Custom rubocop cop probably. Or redefining |
I think defining an |
Fixes rails#50160 The `object_id` name may be used by polymorphic relations where `object` is the best name, like `notification.object`. In that case two columns are created: `object_id` and `object_type`. Update tests and comments to reference `__id__` instead of `object_id` for consistency.
Fixes rails#50160 The `object_id` name may be used by polymorphic relations where `object` is the best name, like `notification.object`. In that case two columns are created: `object_id` and `object_type`. Update tests and comments to reference `__id__` instead of `object_id` for consistency.
With ActiveRecord Before https://github.com/rails/rails/pull/45883/files
it was possible to have a polymorphic relation
object
,implicitly defining
object_type
andobject_id
columns.Expected behavior
Able to use
object
as a name for a polymorphic relationshipActual behavior
An exception
is raised
System configuration
Rails version:
updating from 7.0 to 7.1
Can the
object_id
column be removed from the dangerous attributes list?Having the column with that name was not breaking anything for us for many years, and now we are blocked from upgrading to rails 7.1.
The text was updated successfully, but these errors were encountered: