I have a situation where I can't figure out where to place this business logic.
In rails the best practise is to have fat models and thin controllers.
Now I have a situation where I am interacting (updating mostly) 3-4 model records.
Where should I put this logic? Should I make a 'service' type class and put i开发者_StackOverflow社区t in lib?
Trying to get something to backup the evidence, I found this, chapter 1.2.3.
lib/ Library modules
Which is definitely the most logical place to use for trans-model code.
It's basically the place where we put most of our code when writing acts_as_whatever
gems.
Sometimes it might be worth just creating another class in the models folder that backs to AR based models. A 'model' doesn't have to be limited to a DB table.
精彩评论