Blog
Getting to know your Rails dbconsole (PostgreSQL)
π₯οΈDev
Let's go over a few commands that are helpful when poking around in the Postgres console
databasespostgreSqlrails
Goodbye webpack?
π₯οΈDev
A few backend frameworks are looking to replace webpack with something less heavy-handed, Rails included.
elixirjavaScriptphoenixrailsruby
Adding counter caches to existing models in Rails
π₯οΈDev
Counting the amount of records that exist is a very common task for your database. Rails has a built-in mechanism for caching this value to reduce the number of round trips.
databasespostgreSqlrailsruby
Ensuring a column is unique for an entity in Rails
π₯οΈDev
Sometimes you want to validate that a column is a unique for a given relationship and not across the entire table.
databasespostgreSqlrails
How to use acronyms in the classes of your Rails application
π₯οΈDev
Acronyms are strange to implement in Ruby, but are easy to manage in Rails when leveraging ActiveSupport.
railsruby
Using namespaces to organize your Rails code base
π₯οΈDev
Sometimes you want to namespace areas of your application to group related code together, and Rails has support for this baked in.
architecturerailsruby
Grabbing the last result in common Rails debuggers
π₯οΈDev
Sometimes you want to access the value returned by the last command you wrote into a Ruby REPL. Thereβs a trick for that.
ruby
Using i18n to customize submit button text in Rails
π₯οΈDev
The Rails submit form helper populates the button's text by using a humanized/readable version of the model's class name. Sometimes that isn't idea, but i18n has our backs.
i18nrails
Why I no longer define ActiveRecord scopes with class methods
π₯οΈDev
ActiveRecord scopes can be defined using the scope method or class methods on your model using the self keyword, but there is an important difference between the two.
rails
Using dbconsole to index and test Rails query performance on the fly
π₯οΈDev
Rails ships with a command for loading up the REPL for your database that can be useful for testing out the effectiveness of adding indexes to lower query response times.
databasesperformancepostgreSqlrails
Two features of Ruby that helped me demystify Rails
π₯οΈDev
Rails has been said to have "too much magic". I think a lot of that can be attributed to two of its syntax decisions.
railsruby
Returning an empty result set from ActiveRecord that doesn't break method chaining
π₯οΈDev
Rails 4 added the null object pattern to ActiveRecord relations. Let's see how we can leverage it to avoid no method errors down the stacktrace.
databasesrails
Adding custom data types to your Postgres database in Rails
π₯οΈDev
Postgres allows you to create a custom column type with its own constraints. Letβs try implementing one in Rails.
databasespostgreSqlrails
Wrapping business logic in ActiveRecord transactions
π₯οΈDev
Creating records in a loop is easy with ActiveRecord, but how do we handle rolling back changes when something goes awry?
databasespostgreSqlrails
Why does ActiveRecord store empty strings?
π₯οΈDev
I recently realized a puzzling behavior of ActiveRecord.
databasespostgreSqlrails
Creating related records with ActiveRecord
π₯οΈDev
Setting foreign keys manually is fine, but ActiveRecord gives us another way.
railsruby
RESTful routes for all the things
π₯οΈDev
Rails allows you to define custom routes as you see fit, but what happens to the architecture of our application if we try to limit ourselves to using RESTful actions in our controllers?
architecturerailsrest
Copy text to a userβs clipboard using Stimulus.js
π₯οΈDev
A copy to clipboard button can really make the lives of your users a bit easier. Letβs build one using Stimulus.js.
javaScript
Restart your Rails server with less ceremony
π₯οΈDev
Tired of stopping and starting your Rails server? Rails has a command for that!
devToolsrails
Squashing N+1 queries in Rails
π₯οΈDev
One of the drawbacks of using an ORM like ActiveRecord is unknowingly building a query that splits into thousands in your views.
databasesrails
Configuring Ruby REPLs
π₯οΈDev
Sometimes you want to push something from your Rails console to your clipboard. Letβs configure your Ruby consoles globally to make it easy.
devToolsruby
Configuring your rails new command with a railsrc file
π₯οΈDev
The rails new command ships with a lot of flags to tweak Rails to fit your needs. If you find yourself using the same flags consistently, you might want to make them added by default.
devToolsrails
Guaranteeing unique values for a database column in Rails
π₯οΈDev
ActiveRecord provides a unique validation, but is it enough?
databasesrailsruby
Breaking the space-time continuum in your test suite with Timecop
π₯οΈDev
Where weβre going, we donβt need roads. Sometimes you need to time travel or freeze time altogether in the world of your test suite. Letβs do it with Timecop.
devOpsrailsrubytesting
Coulda, woulda, shoulda-matchers
π₯οΈDev
Test the stuff youβre constantly doing in Rails without all of the hassle.
railstesting
Generating randomized test data in Rails with Faker
π₯οΈDev
Faker is a lighthearted library that pairs well with FactoryBot to generating fake data.
railsrubytesting
Rails test objects up and running with FactoryBot
π₯οΈDev
Let's talk about how to spin up objects and database records for our tests using factory_bot_rails from thoughtbot.
railsrubytesting
Manage programming runtime versions with FZF and asdf
π₯οΈDev
Manage versions for multiple programming languages in a sane way using a powerful combo of two CLI tools.
clidevTools
Migrating or rolling back a specific migration in Rails
π₯οΈDev
Sometimes you just need to target a single database migration in Rails. Let's talk about how to do so.
databasesrails
Use italics in any VS Code theme
π₯οΈDev
A quick guide to making any VS Code theme appear like a theme with an "Operator" variant.
vsCode
MIT 6-3
π₯οΈDev
An unofficial guide for "enrolling" in MIT's Computer Science and Engineering using their free online courses.
computerScience
VS Code boot tasks
π₯οΈDev
A quick walkthrough of setting up a boot task in VS Code to kick off your project's processes.
devToolsrailsvsCode
Saving your VS Code settings on GitHub
π₯οΈDev
Setup an easy system for making your VS Code settings transferrable to a new machine.
devToolsgitvsCode
Test-Driven Development (TDD) with Rails 5: Model Testing
π₯οΈDev
This is the third post of a three part series that covers using test-driven development in Rails 5.
railsrubytesting
Test-Driven Development (TDD) with Rails 5: Integration Testing
π₯οΈDev
This is the second post of a three part series that covers using test-driven development in Rails 5.
railstesting
Test-Driven Development (TDD) with Rails 5: System Testing
π₯οΈDev
This is the first post of a three part series that covers using test-driven development in Rails 5.
railstesting
Python-backed Vim super snippets with UltiSnips
π₯οΈDev
Let's walk through building some crazy powerful vim snippets using python and UltiSnips.
devToolspythonvim
vim-stargazer: fuzzy find and open your starred repositories from Vim
π₯οΈDev
Introducing a vim plugin that allows you to fetch, fuzzy find, and open your starred repositories on GitHub.
rubyvim
Blogging with Vim
π₯οΈDev
Blogging in vim sounds painful (borderline sadistic) at first, but it can be configured to be a very pleasant experience.
vim
Formatting text to a desired width in vim
π₯οΈDev
Formatting lines in vim to wrap at your preferred text width.
vim
Vimming around in Firefox with Vimperator
π₯οΈDev
[Vimperator has sadly been deprecated] Using vimperator to navigate Firefox with your keyboard.
devToolsvim
Searching for answers in open source on GitHub
π₯οΈDev
A quick tip on how to search open source code for examples to learn from.
git