News for hackers. Stuff that matters.
Re:Put Callback Logic Into Callback Objects [Rails] by camwest on Thursday March 08, 2012 @08:39AM (#3679641)
Create a RequestFactory which is responsible for creating valid requests, put the hash generator in there. Then use the factory in the controller instead of directly creating the model.

That way you don't have the indirection of an ActiveRecord callback and you have your process of creating a request and assigning it a unique hash in a straightforward single process.

Re:Put Callback Logic Into Callback Objects [Rails] by nagnatron on Thursday March 08, 2012 @08:50AM (#3679672)
This makes sense. Thanks.
Re:Put Callback Logic Into Callback Objects [Rails] by camwest on Thursday March 08, 2012 @08:58AM (#3679694)
I've learned this the hard way. I have an app which has callback chains through 5+ models and it's basically impossible to figure out what's going on.

-C