0

It become a nightmare when we have a complicate logic in ActiveRecord model. Now we are maintaining a complicate rails project. As one of the most complex models, we have more than 4000 lines code and more than 140 callbacks. It is depressed when new features comes in. No one can tell which part is impacted and need to update.

Does anyone has suggestion for the case? Any better idea to organize the callbacks? Or we need to avoid to abuse using callbacks, and any other solution need involved?

2 Answers2

0

You need think using the DCI pattern. Is do to your case. You can have some information about that in this SO questions : DCI - Data, Context and Interaction - Successor to MVC?

Community
  • 1
  • 1
shingara
  • 46,608
  • 11
  • 99
  • 105
0

You could move some callbacks to Observers . This can make your model lighter.

santuxus
  • 3,662
  • 1
  • 29
  • 35
  • I think we are over used callbacks. If i change callbacks into Observer. It will be over used observer. The problem is still there. – liangyan.cn Mar 15 '12 at 05:15