An email newsletter, with one Ruby/Rails technique delivered with a ‘why?’ and a ‘how?’ every two weeks. It’s deliberately brief, focussed & opinionated.
Don’t miss my next post, sign up to the One Ruby Thing email and get my next post in your inbox.
- Do not use .all without pagination or a .limit
- Be specific when defining your routes
- Turn off the bits of Rails you don't use
- Use Rails URL helpers outside views and controllers
- Use Enhanced Memoization for false/nil with defined?
- Convert a two character ISO country code to an emoji flag
- Memoize Expensive Code
- Read the .ruby-version into your Gemfile
- Alt:BrightonRuby: An Online Ruby Conference — June/July 2020
- ‘Fix’ first & last by explicitly setting implicit ordering
- All Your Mailer Views in One Place
- Calculate a mean average from a Ruby array
- Be Suspicious of Join Tables
- Use Loose Ruby Versioning in Your Gemfile
- Ensure you correctly build your caching keys
- Write One Test
- Use GitHub Actions for Rails CI with Postgres
- Use Active Support in Rails for deprecation messages
- A Active Model validator for Stripe Ids
- Use a custom validator
- Clamp for min/max values
- Consider Value Objects
- Using strftime in a Rails view is probably a mistake
- Don’t Email From Active Record Callbacks
- Watch Out For nil in Ranges
- Be Aware of nil values when using where.not()
- Prevent Links in Text Fields to Foil Spammers
- Protect your sign up form with Rack::Attack
- Clean up broken .dev domains
- Don't use instance variables in partials
- Secure Your Rails Staging Environment with HTTP Basic Authentication
- Be Careful Assigning to has_one Relations
- Replace Timecop With Rails’ Time Helpers in RSpec
- Use Multiple Migrations When Adding Database Constraints
- Always Force Booleans to be True or False
- Write long strings with wiggly HEREDOCs
- A scope should return a scope
- Don’t Loop & Do Work in Jobs
- Using pluck can save a bunch of memory
- Careful with present? when using ActiveRecord scopes
- Use the presence method
- Delegate to simplify your code
- Ignore PHP bots with Rack::Attack
- Use beginning and end of string in regular expressions
- Active Record’s first and last may not mean what you think
- A job should know whether to run itself
- Use Hash#fetch when using Rails params in controllers
- Stop robots and crawlers causing errors in your Rails application
- Check Your Database Indexes For ActiveRecord Scopes
- Only use named scopes outside models
- Avoid Writing SQL When Using ActiveRelation
- Enumerable avoids using temporary variables when looping
- Extract conditionals into well-named methods
- Be sparing when using unless
- Truthiness in Conditionals
- Set your page title in the view template using content_for
- Choose UUIDs for model IDs in Rails
- Use a pull request template
- Use simplecov in your Rails test suite
- Rescue specific errors. Avoid rescuing StandardError. Don’t rescue Exception.
- Don’t use default_scope. Ever.
- Use Rails’ naming conventions for dates & times
- Rails Naming Cringes
- AMP Project Pages on Ruby on Rails
- Simple Ruby/Rails Setup on macOS
- Benchmarking each_with_object Against inject when building Hashes from Arrays
- Serving a Jekyll Blog using Heroku
- Web Services used at ImpulseFlyer
- RedDotRubyConf 2012: Wrap up