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

How Many Types Of Call...

Câu trả lời

There are four main types of callbacks available in Ruby on Rails:

  1. before_validation: Runs before validation so you can make sure your data is in good shape[1].

  2. before_save: This happens just before the record is saved, making it great for final adjustments[1].

  3. after_save: This runs right after the record is saved for things like sending notifications[1].

  4. after_commit: This occurs after the transaction is committed, ensuring data integrity[1].

Rails provides a total of nineteen callbacks in total, which give a lot of control over how to react and prepare for each state in the Active Record life cycle[3]. Some other callback types include:

  • before_create, after_create: Called before/after object creation
  • before_update, after_update: Calle...
senior

senior

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

middle

What Is The Difference Between Delete And Destroy ?

senior

What is the difference between content_for and yield ?

middle

What Things We Can Define In The Model?

Bình luận

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

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