How to detect time-overlapping-records in Postgres + Rails

```ruby Model .where("TSRANGE(?, ?, '()') && TSRANGE(starts_at, ends_at, '()')", starts_at, ends_at) .where.not(id: record_id) .exists? ``` Bot...

Rails ERD diagram visualisation online

Manual: 1. Go to 2. Click *import* and choose *Import from Rails (schema.rb)* 3. Paste schema.rb content 4. voilĂ

How to deal with RSpec time precision error

In some cases, Ruby uses higher precision to represent time than the DB. When we compare a timestamp before and after saving to the DB it might not be equal.

Rails migration decimal precision scale

Rails migration decimal precision scale explained quasi visually ``` 123.45678912345 <- scale -> <- precision -> ```

How to use helper methods in mailer templates

How to use helper methods in mailer templates? Instead of this "include YourHelper" use this "add_template_helper YourHelper" in YourMailer

Example tmux script for Rails

Shell script that will start a tmux session with Rails console and server in side panes

Compiling ES6 syntax with Uglifier on

When you try to compile ES6 syntax with Uglifier gem initialized you get this error: ``` Uglifier::Error: (...) To use ES6 syntax, harmony mode must be e...

Brakeman - An awesome gem that scans your app against vulnerabilities.

To use Brakeman, the only thing is to install the gem: ``` $ gem install brakeman ``` and then run the single command in Rails application's root dir...

How to drop a production database in Rails 5

I encountered a problem when dropping a production database. Here's the solution

Make RSpec shared examples easier to understand with this one trick!

This guy makes his shared examples easier to understand. Overpaid consultants hate him!

When to use let, let! and before in RSpec

When to use let, let! and before in RSpec.