Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Why not using AR standard callback propagation instead of creating version after_update/create ? #108

Open
itkin opened this issue Jul 11, 2014 · 0 comments

Comments

@itkin
Copy link

itkin commented Jul 11, 2014

Hello,

I'm implementing your gem in one project (thx for wthe good work btw! ;-) ), and was wondering why you rely on after_create & update callback when creating a version.

  #creation.rb line 8
  after_create :create_initial_version, :if => :create_initial_version?
  after_update :create_version, :if => :create_version?
  after_update :update_version, :if => :update_version?

There is a rails standard feature for callback propagation between associated models , wouldn't it be more interesting to do something like that :

  #creation.rb line 8
  before_create :instanciate_initial_version, :if => :create_initial_version?
  before_update :instanciate_version, :if => :create_version?
  before_update :instanciate_version, :if => :update_version?

I'm perhaps missing something here, so let me know if you see any drawback to such evolution, but it would reduce the number of db commit and ensure that the after_commit include the last version instance ...

@itkin itkin changed the title Why not using AR standard callback system instead of creating version after_update/create ? Why not using AR standard callback propagation instead of creating version after_update/create ? Jul 11, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant