3 ms·
Put chubby models on a diet with concerns - Rails
- krakensden 14y agoClearly the opportunity to come up with a truly tasteless name was missed. I await the fork eagerly.
- amalag 14y agoFrom the API page (http://api.rubyonrails.org/classes/ActiveSupport/Concern.html http://api.rubyonrails.org/classes/ActiveSupport/Concern.htm...) it seems to do two things, 1. resolve module dependencies 2. eliminate some ruby boilerplate in the module code. I kind of liked the idea of extending the instances instead of including in class, to add functionality to instances instead of all objects of the class, but this keeps your model's fat, just the fat is distributed so it's not in the model's single file.
- venus 14y agoI love DHH but passages like this "concern" me (lol): > Here’s a Dropboxed concern that we mix into just the Person model Right. So extracting a section of code into a mixin .. and then mixing it into a single model? That's just moving the code elsewhere and using a fancy method to inject it back in! It's not cleaning up anything! For anyone interested in practical techniques to rethink, refactor and really take the knife to your overweight models this post is a good start: http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/ http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decomp...
- jasonwatkinspdx 14y agoDupe of http://news.ycombinator.com/item?id=4937917 http://news.ycombinator.com/item?id=4937917 Looks like andreiursan just cut off a couple characters from the permalink slug, which the 37s blog ignores, to get around the duplicate submission detection.