Rails < 5: How to get after_commit callbacks fired in tests

Posted Over 5 years ago by Emanuel.

If you use transactional_fixtures or the database_cleaner gem with strategy :transaction, after_commit callbacks will not be fired...

Rails: How to check if a certain validation failed

Posted Over 5 years ago by Arne Hartherz.

If validations failed for a record, and you want to find out if a specific validation failed, you can leverage...

How to write a good changelog

Posted Over 5 years ago by Emanuel.
keepachangelog.com

We want to keep a changelog for all gems we maintain. There are some good practices for writing a changelog...

HTML forms with multiple submit buttons

Posted Over 5 years ago by Henning Koch.

Most forms have a single submit button that will save the record when pressed. Sometimes a form needs additional submit...

SSH: X-Forwarding

Posted Over 5 years ago by Tobias Kraze.

If you need to run a program on a remote machine (e.g. to your office PC) with a graphical UI...

Best practices: Large data migrations from legacy systems

Posted Over 5 years ago by Tobias Kraze.

Migrating data from a legacy into a new system can be a surprisingly large undertaking. We have done this a...

Chrome bug: Wrong stacking order when transitioning composited elements

Posted Over 5 years ago by Dominik Schöler.

Google Chrome has a subtle rendering bug that hits me once in a while. It usually occurs in sliders with...

Haml: Generating a unique selector for an element

Posted Over 5 years ago by Henning Koch.

Having a unique selector for an element is useful to later select it from JavaScript or to update a fragment...

Devise: Invalidating all sessions for a user

Posted Almost 6 years ago by Natalie Zeumann.

Background information about session storage in Rails Rails has a default mechanism to store the session in the CookieStore. This...

ActiveRecord::Store: migrate data in store

Posted Almost 6 years ago by Daniel Straßner.

When you need to store structured data (like Ruby hashes) in a single database column with ActiveRecord, a simple way...

ActionMailer: How to send a test mail directly from the console

Posted Almost 6 years ago by Daniel Straßner.

If your rails application is unable to send mails, it might be useful to debug your settings using the rails...

PostgreSQL: How to show table sizes

Posted Almost 6 years ago by Arne Hartherz.
wiki.postgresql.org

When you have a large PG database, you may want to find out which tables are consuming the most disk...

User-defined Order in SQL

Posted About 6 years ago by Henning Koch.
begriffs.com

The attached article explains options you have to store the order of items in a database table. The simplest solution...

How to resize your boot partition when there is an encrypted partition after it

Posted About 6 years ago by Arne Hartherz.

Boot partitions from installations prior to the 16.04 era are terribly small. When you install updates and encounter errors due...

Don't sum up columns with + in a SQL query if NULL-values can be present.

Posted About 6 years ago by Natalie Zeumann.

Don't sum up columns with + in a sql-query if NULL-Values can be present. MySQL and PostgreSQL cannot...

Geordi 1.9 released

Posted About 6 years ago by Florian Heinle.
github.com

geordi delete_dumps [directory] Recursively search for files ending in *.dump and offer to delete those. When no...

Running Rails 2 apps with modern MariaDB SQL server

Posted About 6 years ago by Henning Koch.

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

Understanding SQL compatibility modes in MySQL and MariaDB

Posted About 6 years ago by Henning Koch.

MySQL and MariaDB have an SQL mode setting which changes how MySQL behaves. The SQL mode value is comprised of...

PostgreSQL: Upgrading your user to a superuser

Posted About 6 years ago by Dominik Schöler.
stackoverflow.com

Your default postgres user is named like your linux user. That default user has limited access privileges, which can cause...

Mysql::Error: BLOB/TEXT column can't have a default value

Posted About 6 years ago by Emanuel.
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...

Chrome: Making high-resolution website screenshots without add-ons

Posted About 6 years ago by Henning Koch.

If you want to make a screenshot of a website that works well in print or on a high-DPI...

Decide whether cronjobs should run on one or all servers

Posted About 6 years ago by Judith Roth.

Understanding your type of cronjob Some cronjobs must only run on a single server. E.g. when you run nightly batch...

Ruby: Using all? with empty collection

Posted About 6 years ago by Emanuel.

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

Carrierwave: Deleting files outside of forms

Posted Over 6 years ago by Dominik Schöler.

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