Câu hỏi phỏng vấn Ruby on Rails
Câu hỏi

What Is The Difference Between Delete And Destroy ?

Câu trả lời

Here is an explanation of the difference between the delete and destroy methods in Ruby on Rails:

delete vs destroy

In Ruby on Rails, both delete and destroy are methods used to remove records from the database, but they differ in their behavior and consequences:

delete

  • The delete method removes a record from the database without executing any callbacks.
  • It is faster than destroy because it skips the callback chain.
  • delete does not trigger the before_destroy and after_destroy callbacks.
  • It is useful when you want to remove records quickly without executing any additional logic.
  • Example: User.delete(1) or User.where(email: 'example@example.com').delete_all...
middle

middle

Gợi ý câu hỏi phỏng vấn

senior

What is the difference between content_for and yield ?

junior

What do you mean by the term Scaffolding and what sort of advantages the Ruby can offer when it comes to same?

junior

Mention what are the limits of Ruby on Rails?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào