When your application is running on a multi-server setup, application logs are stored per server (unless you choose a...

You might have some trouble running a Rails LTS 2 app with MySQL 5.7. If you don't want to...

When you have string contents (e.g. a generated binary stream, or data from a remote source) that you want to...

stackoverflow.com

mysql> SELECT @@global.version; +------------------+ | @@global.version | +------------------+ | 5.6.30 | +------------------+ 1 row in set (0,00 sec) MySQL 5.6 Reference Manual says "BLOB and TEXT...

Enumerable#all? returns true for an empty collection. This totally makes sense but you have to think about it when...

makandra dev
fontawesome.com

Font Awesome version 5 changed some icon names, and introduces new prefixes fab, far, and fas. There is a JavaScript...

TL;DR Use user.update!(remove_avatar: true) to delete attachments outside of forms. This will have the same behavior as...

To check which elements an ActiveRecord relation contains use the contain_exactly matcher. describe User do let!(:admin) { create(:user...

This is a small example on how you can check if your Postgres index can be used by a specific...

You should avoid using application models in your migrations. But how else could you create records in a migration?

When your public-facing application has a longer downtime for server maintenance or long migrations, it's nice to setup...

You need to set the :inverse_of option manually for relations that have an association to a polymorphic model. Otherwise...

After loading a staging dump into development, you might get an ActiveRecord::EnvironmentMismatchError when trying to replace the database (like...

When localizing model attributes via I18n you may run into errors like this: I18n::InvalidPluralizationData: translation data {...

...} can not be...

There are many approaches out there how you can import data from a legacy application to a new application. Here...

github.com

Use Traim to build a RESTful API for your ActiveRecord models with very little code. Traim assumes your API resources...

You can not use the hash_including argument matcher with a nested hash: describe 'user' do let(:user) { {id: 1...

ActiveRecord::RecordNotFound errors provide quite meaningful error messages that can provide some insight on application details. Consider the following:

This card will show you a cool way to define a class using Struct.new. A common usecase for Structs are...

Since Rails 5, domain models inherit from ApplicationRecord by default. This is the place to put code that should be...

Rails supports time zones, but there are several pitfalls. Most importantly because Time.now and Time.current are completely different things and...

Database connections are not thread-safe. That's why ActiveRecord uses a separate database connection for each thread.

makandra dev

This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the...

github.com

The parallel-gem is quite easy to use and can speed up rendering time if you want to render the...