To allow HTTP 304 responses, Rails offers the fresh_when method for controllers. The most common way is to pass...

For Rails models where only one of multiple attributes may be filled out at the same time, there is no...

greg.molnar.io

Greg Molnar has written a neat article about creating a single-file Rails app. This is not meant for production...

When working with feature branches, stale branches pile up over time. It's best to remove them right after merge...

Recently we detected a memory leak in one of our applications. Hunting it down, we found that the memory leak...

paweldabrowski.com

The linked content includes a few design patterns implemented with Ruby on Rails. What is the card indented to achieve...

SELECT pg_size_pretty(pg_database_size('some-database')); Example SELECT pg_size_pretty(pg_database_size('cards_p')); ----------------

When paginating records, we usually need to know the number of total records in order to render pagination links. Popular...

joshmcarthur.com

I recently wanted to add a model for address information but also wanted to add a unique index to those...

blog.saeloun.com

Imagine these models and associations: class Deck < ApplicationRecord has_many :cards end class Card < ApplicationRecord belongs_to :deck, optional: true...

It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your...

Testing file download links in an end-to-end test can be painful, especially with Selenium. The attached download_helpers.rb provides...

There is a way to use multiple databases in Rails. You may have asked yourself how you're able to...

tl;dr You can use attribute? as shorthanded version of attribute.present?, except for numeric attributes and associations. Technical Details

You can use Unpoly's up.on with a named listener function and immediately unbind this event listener with { once: true...

tl;dr: Use the URLSearchParams API to make your live easier if you want to get or manipulate query parameters...

Redis.current will be removed without replacement in redis-rb 5.0. Version 4.6.0 adds deprecation warnings for Redis.current and Redis.current=: `Redis.current...

RSpec's let allows you to super into "outside" definitions, in parent contexts. Example: describe '#save' do subject { described_class.new(attributes...

Sometimes we write plain SQL queries in migrations so we don't have to mock ActiveRecord classes. These two migrations...

When using where.not with a Hash of multiple attributes, Rails applies logical NAND (NOT (A AND B)). This contrasts with...

You can use RSpec::Matchers.define_negated_matcher to define a negated version of an existing matcher. This is particularly useful...

dev.to

In my case [...] the catalog is an XML that contains all kinds of possible products, categories and vendors and it...

TL;DR When using Cache-Control on a Rails application, make sure the Vary: Accept header is set.

makandra dev

Field error steps Spreewald's The...

...field should have an error and The...

...field should have the error...

...steps now...