callbacks: *_save as syntactic sugar for *_create and *_update

34 views
Skip to first unread message

Charles Rudolph

unread,
Sep 9, 2015, 1:44:08 PM9/9/15
to Ruby on Rails: Core
Looking over the callback order I am thinking it would be nice to simplify things.
The current callback list is as follows

****************************************
before_validation 
- validate      
after_validation
before_save          
around_save
before_create/update
around_create/update
- save
after_create/update
after_save
after_commit/after_rollback
****************************************

This is overly complicated to me and something I would like reduced to:

****************************************
before_validation
- validation    
after_validation     
before_create/update
around_create/update
- create/update
after_create/update
after_commit/after_rollback
****************************************

before/around/after_save can just become syntactic sugar for calling both before/around/after_create and before/around/after_update.

This isn't backward compatible if an application relies on the special ordering of save vs create/update callbacks, instead of based on the order of definition. 
In my opinion, that is a gotcha instead of a feature anyway.

Jason King

unread,
Sep 10, 2015, 12:21:34 PM9/10/15
to Ruby on Rails: Core
What benefit do you see this as being?
Reply all
Reply to author
Forward
0 new messages