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 dependent: :destroy
requires id
on the associated object, raises NoMethodError: undefined method `to_sym' for nil:NilClass
#31022
Comments
Seems this is a duplicate of #25437 issue. Briefly: when you use |
+1 to @kennyx46 - That process - like most ActiveRecord processes - expects models to have a primary key (either tool = Tool.create
tool.destroy |
It is expected behavior. See #25347 (comment) |
Thank you for the update. |
I had the same issue. Used to have a table like this:
With it, Active Record was always sending me warnings:
And fixed creating a primary key for it:
Not my favorite solution, but fixed... |
Steps to reproduce
Expected behavior
The resource should be destroyed without raising an error.
Actual behavior
NoMethodError: undefined method `to_sym' for nil:NilClass
System configuration
Rails version:
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
Ruby version:
Rails 5.0.6
The text was updated successfully, but these errors were encountered: