This Week in Ruby, 19th October
Oct. 19, 2012
ActiveSupport Method of the Week: String#inquiry
Wraps the current string in the
ActiveSupport::StringInquirer class, which gives you a prettier way to test for equality. Example:
env = "production".inquiry env.production? # => true env.development? # => false
For the record, this is actually how Rails implements things like
Rails.env.production? behind the scenes.
7 Patterns to Refactor Fat ActiveRecord Models (Murray)
An interesting article about how to take the next step from Skinny Controller, Fat Model towards Skinny Everything. Rather than just suggesting pulling everything out into Modules, which just hides the issues it actually gives some good suggestions of alternatives. I think the article would benefit from before and after code snippets, as the "this is how I do it" snippets don't really tell the whole story; it's not clear how they are used in context, nor how, for want of a better word, weird a rails app would look using these approaches. Still, it's a good article and the approaches seem sane.
RubyTapas: Short screencasts of gourmet Ruby code (Leo)
A new screencast series from Avdi Grimm (who needs no introductions). Personally I love the focus on short, simple nuggets of Ruby information, and I have found the series very enjoyable so far. Four free episodes have been published already, and you get eight more (and counting) when you subscribe.
Another great tool for testing responsive layouts. This one looks a bit better, then the others (http://screenqueri.es/ for instance) because you can see all the 'device' resolutions on one page. You also can specify what device resolutions you want to use.
GreenSock JS Tutorial (Rob)
My new favourite Rails trick:
Using remote js forms? You will find simply disabling the button on click will likely disable the button before submitting the form, which is well… annoying but reasonable. Instead use the following to force your submit to disable the link until the form is submitted.
:disable_with => 'Please wait..'
Rails 4 Whirlwind Tour (Jolyon)
XPDay 2012 (Ben)
Ben wants you to go to XPDay London. 26-27th November.
A thought on the minutiae of European law (Matt Frank)
The provisions of the United Kingdom's Data Protection Act apply to data stored or transmitted in the UK, right? Wrong. Oh, so it's the EU then? Wrong again. They're applicable to all countries within the European Economic Area which is distinct from the European Union: http://script-ed.org/?p=324
Can't tell your EEA from your EFTA or your CoE? Help is at hand: http://bit.ly/eu-venn
Lightning captured at 7,207 images per second (Ben)
Ben sends in this pretty impressive high-speed camera video of lightning striking Earth. If you want to know more, be sure to also check out the "What If?" article on lightning.