Answer the question
In order to leave comments, you need to log in
How does ActiveRecord even work?
Looked at an example of a command to delete an entry from Ruby
user = User.find_by(name: 'David')
user.destroy
user = User.destroy(name: 'David')
Answer the question
In order to leave comments, you need to log in
user = User.destroy(name: 'David')
why assign the object to be deleted to a variable?
usually done like this:
User.find_by(name: 'David').destroy
or if you need to delete all records where name: 'David' :
User.where(name: 'David').destroy_all
documentation is full on the basics of AR, including .h. and in Russian
Why, did Roskomnadzor ban the documentation?
devdocs.io/rails~4.2/activerecord/relation#method-...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question