Open a MySQL root shell and use this command: PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY) + INTERVAL 0...

When you have a string containing umlauts which don't behave as expected (are not matched with a regexp, can...

ActiveRecord caches results of SQL queries. If you want to discard the cached results for one model, you can call...

makandra dev

When you want the table headers to always stay around (e.g. because that table is huuuge), use the code below...

robots.thoughtbot.com

Declare an enum attribute where the values map to integers in the database, but can be queried by name.

medium.com

When you, as a developer, look at the choices used to build a particular application, you’re blown away at...

By default, Rails' validates_uniqueness_of does not consider "username" and "USERNAME" to be a collision. If you use MySQL...

Store each models version in a separate table class Post < ActiveRecord::Base has_paper_trail :class_name => 'PostVersion' end

makandra dev

Just found out about a great feature in Rails that seems to be around since Rails 2. Start a console...

You might have a table without a primary key set in MySQL. You can fix this by adding a primary...

codeka.com.au

For reasons that completely escape me, MySQL 5.x limits UTF-8 strings to U+FFFF and smaller.

Like in any language, a FLOAT will eventually corrupt data due to rounding errors. Please use DECIMAL, which has well...

robots.thoughtbot.com

Arel is a library that was introduced in Rails 3 for use in constructing SQL queries. Every time you pass...

I had a huge MySQL dump that took forever (as in: days) to import, while I actually just wanted to...

dev.mysql.com

A MySQL DECIMAL column is used when it is important to preserve exact precision. It takes two parameters, where...

When you do something like this in your code: def var_value @var ||= some_expensive_calculation end

Give the table a style table-layout: fixed Give the cells in the first row a width The same width...

TLDR: This card explains which threads and processes interact with each other when you run a Selenium test with Capybara...

tl;dr: Using has_many associations with a :through option can lead to lost or duplicate records. You should avoid...

We've since created ActiveType which has a restricted subset of Virtus' features. It might be enough for your needs...

This error occurs when you already have a database.yml which defines the database for the cucumber environment instead of test...

stackoverflow.com

When you want to find out the data type of an attribute, you can just use ActiveRecord's columns_hash...

dev.mysql.com

Usually our mysql queries are not case sensitive. In order to query case sensitive, you can use the mysql COLLATE...