On destruction of a restful resource, I want to guarantee a few things before I allow a destroy operation to continue? Basically, I want the ability to stop the destroy operation if I note that doing so would place the database in a invalid state? There are no validation callbacks on a destroy operation, so how does one "validate" whether a destroy operation should be accepted?
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Disable Browser onUnload on certain links?
- Eager-loading association count with Arel (Rails 3
- How to specify memcache server to Rack::Session::M
相关文章
- Ruby using wrong version of openssl
- Right way to deploy Rails + Puma + Postgres app to
- AWS S3 in rails - how to set the s3_signature_vers
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- How to add a JSON column in MySQL with Rails 5 Mig
- How to create a CFuncType in Python
- “No explicit conversion of Symbol into String” for
You can also use the before_destroy callback to raise an exception.
I was hoping this would be supported so I opened a rails issue to get it added:
https://github.com/rails/rails/issues/32376
I have these classes or models
Now when you delete an enterprise this process validates if there are products associated with enterprises Note: You have to write this in the top of the class in order to validate it first.
It is what I did with Rails 5: