Rails and Postgres: How to test if your index is used as expected

Posted Over 6 years ago by Emanuel.

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

Form letters with LibreOffice Writer

Posted Over 6 years ago by Henning Koch.

This is painful. Consider using Microsoft Office or switching careers. If you need to write < 20 letters consider doing it...

Error during Rails 5 upgrade: Environment data not found in the schema

Posted Over 6 years ago by Dominik Schöler.
blog.bigbinary.com

This error is raised because your old database does not have a configured environment yet, which Rails 5 enforces.

Active Model Serializers Dokumentation

Posted Over 6 years ago by Andreas Robecke.
github.com

Rails: Migration helper for inserting records without using models

Posted Over 6 years ago by Dominik Schöler.

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

PostgreSQL: WITH Queries (Common Table Expressions)

Posted Over 6 years ago by Arne Hartherz.
postgresql.org

PostgreSQL's Common Table Expressions (CTEs) can be used to extract sub-queries from bulky SQL statements into a temporary...

PostgreSQL's OVERLAPS operator is not fully inclusive

Posted Over 6 years ago by Henning Koch.

PostgreSQL supports the SQL OVERLAPS operator. You can use it to test if two date ranges overlap: => SELECT ('2001-02...

Git: creating and deleting a tag

Posted Over 6 years ago by Daniel Straßner.

Git has two kind of tags: annotated lightweight Annotated tags are stored as full objects in the Git database. They...

Cucumber: Identifying slow steps that drag down your test speed

Posted Over 6 years ago by Dominik Schöler.
relishapp.com

In most projects I know, Cucumber test suite speed is not an issue. Of course, running 350 features takes its...

Webservice to test and inspect requests

Posted Over 6 years ago by Tobias Kraze.
requestb.in

Requestb.in is a webservice that gives you a temporary URL you can use to test request. The page will automatically...

How to install packages from newer Ubuntu releases

Posted Over 6 years ago by Florian Heinle.

We're usually running Ubuntu LTS versions. Sometimes newer hardware requires packages from more recent Ubuntu releases that only come...

Fixing flaky E2E tests

Posted Over 6 years ago by Henning Koch.

An end-to-end test (E2E test) is a script that remote-controls a web browser with tools like Selenium...

Be careful to use correct HTTP status codes for maintenance pages

Posted Over 6 years ago by Henning Koch.

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

Async control flow in JavaScript: Promises, Microtasks, async/await

Posted Over 6 years ago by Henning Koch.

Slides for Henning's talk on Sep 21st 2017. Understanding sync vs. async control flow Talking to synchronous (or "blocking...

How to fix broken font collisions in wkhtmltopdf

Posted Over 6 years ago by Michael Leimstädtner.

If you are using PDFKit / wkhtmltopdf, you might as well want to use custom fonts in your stylesheets. Usually this...

Association to polymorphic model does not determine inverse_of automatically

Posted Over 6 years ago by Emanuel.

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

RSpec: How to define classes for specs

Posted Over 6 years ago by Arne Hartherz.

RSpec allows defining methods inside describe/context blocks which will only exist inside them. However, classes (or any constants, for that...

Rails: render a template that accepts a block by using the layout option of render

Posted Over 6 years ago by Andreas Robecke.

Let's say you have a form that you render a few times but you would like to customize your...

How to change the class in FactoryBot traits

Posted Over 6 years ago by Arne Hartherz.
github.com

FactoryBot allows a :class option to its factory definitions, to set the class to construct. However, this option is not...

How to avoid ActiveRecord::EnvironmentMismatchError on "rails db:drop"

Posted Over 6 years ago by Arne Hartherz.

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

Postgres: How to force database sessions to terminate

Posted Over 6 years ago by Emanuel.

If another session is accessing your database you are trying to reset or drop you might have seen the following...

Ruby: A small summary of what return, break and next means for blocks

Posted Over 6 years ago by Emanuel.
docs.ruby-lang.org

Use return to return from a method. return accepts a value that will be the return value of the...

Custom Ruby method Enumerable#count_by (use for quick statistics)

Posted Over 6 years ago by Dominik Schöler.

I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method...

Rspec: around(:all) and around(:each) hook execution order

Posted Over 6 years ago by Emanuel.

around(:suite) does not exist. around(:all) runs after before(:all) and before after(:all). around(:each) runs before...