Andy CrollEnumerable avoids using temporary variables when loopingSome of my favourite Ruby features are to be found in the Enumerable module. You can read more about it in the Ruby documentation.Mar 16, 2018Mar 16, 2018
Andy CrollBe sparing when using unlessOne of Ruby’s strengths is its delightful, built-in syntactic sugar. One example of this is the keyword unless, which you can use in place…Mar 16, 2018Mar 16, 2018
Andy CrollTruthiness in ConditionalsRuby’s conditional syntax is ‘truthy’, meaning that any statement in a conditional that evaluates to nil is considered to be equivalent to…Mar 16, 2018Mar 16, 2018
Andy CrollSet your page title in the view template using content_forRails uses content_for as its primary way to store content in one place for use in other views, layouts or helpers. Find out more about…Mar 4, 2018Mar 4, 2018
Andy CrollChoose UUIDs for model IDs in RailsA universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. Sometimes it is referred to as…Mar 4, 20182Mar 4, 20182
Andy CrollUse a pull request templateIf you’re submitting work for review, pull requests are a great way to group related changes and discuss approaches and improvements. The…Mar 4, 2018Mar 4, 2018
Andy CrollExtract conditionals into well-named methodsOne of the simplest (and most effective) ways to refactor is to extract a method. The naming of an extracted method is a great tool for…Jan 21, 2018Jan 21, 2018
Andy CrollUse simplecov in your Rails test suiteA useful way of assessing the effectiveness of your testing is to use the simplecov gem with your Rails application. It counts the number…Jan 15, 2018Jan 15, 2018
Andy CrollRescue specific errors. Avoid rescuing StandardError. Don’t rescue Exception.There are many built-in error classes in Ruby and Rails. Most of these errors are subclasses of Ruby’s StandardError. You can find more…Jan 2, 2018Jan 2, 2018
Andy CrollDon’t use default_scope. Ever.When you would like a scope to be applied across all queries on a model, you can use default_scope. See more in the ActiveRecord Query…Jan 2, 2018Jan 2, 2018