To retrieve only unique combinations of the selected attributes: You can omit rows, where all selected columns are equal with...
Using ActiveRecord's #signed_id and .find_signed methods you can create URLs that expire after some time. No conditionals...
When an object is created / updated, various callbacks are executed in this order: before_validation after_validation before_save
TLDR if you define a equality method for a class you must also implement def hash. Ruby has a lot...
tl;dr You should decouple migrations from models by embedding models into the migration. To use STI in this scenario...
ActiveType::Object inherits from ActiveRecod::Base and is designed to behave like an ActiveRecord Object, just without the database...
To allow HTTP 304 responses, Rails offers the fresh_when method for controllers. The most common way is to pass...
Greg Molnar has written a neat article about creating a single-file Rails app. This is not meant for production...
This should be fixed in the latest LTS-branches of our mysql2 fork, 0.2.x-lts and 0.3.x-lts...
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...
I recently wanted to add a model for address information but also wanted to add a unique index to those...
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...
Sometimes we write plain SQL queries in migrations so we don't have to mock ActiveRecord classes. These two migrations...
Table Of Contents Flexbox wrapping Spacing Long content Prevent an image from being stretched or compressed Lock scroll chaining
In my case [...] the catalog is an XML that contains all kinds of possible products, categories and vendors and it...
We are using Spring in our tests for sequential test execution but not for parallel test execution. And Rails requires...
We had a card that described how to install multiple mysql versions using mysql-sandbox. Nowadays with the wide adoption...
Table of content for the linked article: 1. The `loading=lazy` attribute 2. Email, call, and SMS links
To attach files to your records, you will need a new database column representing the filename of the file...
https://tableconvert.com/ is an online tool to convert tables between different formats (e.g. json, markdown, csv).
In Ruby (almost) everything is an Object. While this enables a lot of powerful features, this concept might be confusing...