Given a record, how to get the DELETE SQL sentence that would be executed if I call the destroy method?

Given a record, how to get the DELETE SQL sentence that would be executed if I call the destroy method?

And I mean, before executing the method:

> element = MyModel.first
> element.what_would_be_the_sql_if_i_call_destroy?
 => DELETE from my_models WHERE id = 1234
> puts 'Thank you Ruby!'

You can check some of the methods listed here :

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs