about 3 years ago

Rails的ActiveRecord提供了很多方便的callbacks,讓開發者在寫controller的時候能夠更加簡潔的程式碼。

** Creating an Object**

• before_validation

• after_validation

• before_save

• around_save

• before_create

• around_create

• after_create

• after_save

• after_commit/after_rollback

** Updating an Object**

• before_validation

• after_validation

• before_save

• around_save

• before_update

• around_update

• after_update

• after_save

• after_commit/after_rollback

** Destroying an Object**

• before_destroy

• around_destroy

• after_destroy

• after_commit/after_rollback

← board has_many posts, 新造物件宣告方式是: @post = @boards.posts.build 。那如果 book has_one :author,請問要怎麼宣告? db 的 transaction 是什麼? →
 
comments powered by Disqus