User.active.to_sql Rails 2 Use either the Edge Rider or fake_arel gem to get #to_sql backported...
Note: ActiveRecord::Base#becomes has a lot of quirks and inconsistent behavior. You probably want to use ActiveType.cast instead.
When using ActionMailer, you can set an array of email addresses as recipients. If this array is generated by e.g...
The attached RSpec matcher exist_in_database checks if a given record still exists in the database and has not...
When you need to insert many records into the same table, performance may become an issue. What you can do...
You will occasionally need to clean out your database while keeping the schema intact, e.g. when someone inserted data in...
MySQL's MIN and MAX functions are for aggregations only. This will not work and produce an error:
Currently, only up to 500 rows of Analytics table data can be exported at a time into CSV format. If...
Although you can access many symbols using the AltGr key you may be missing some, like the en-dash (–) or...
Note: For PostgreSQL you should use advisory locks. For MySQL we still recommend the solution in this card.
This note is a reminder that there is something called AppArmor that could cause weird errors ("File not found", "Can...
On 32bit systems, the maximum representable Time is 2038-01-19 03:14:07 in UTC or 2038-01-19...
Have a backup. Stop MySQL: sudo service mysql stop Move (or copy) your mysql directory. If you want /mnt/mysql to...
This tool is used on our application servers (and called when deploying) but it also works locally. Just call dumple...
When you try to remove a non-existing index using remove_index, the migration will incorrectly pass without an error...
A check if two date or time ranges A and B overlap needs to cover a lot of cases:
This might be due to AppArmor denying the MySQL server access to most of the filesystem. You can instead use...
There are times when you need to send SQL to the database, like this: def self.some_count(field) field = connection.quote...
I love ETags, but there’s something that annoys me: most implementations revolve around pulling a record out of a...
Git allows you to do a binary search across commits to hunt down the commit that introduced a bug.
In regular expressions you can use the zero-width pattern \b to match the beginning or end of a word...
If you need to export data from MySQL to a CSV, you can profit from really fast built-in methods...
To clear the query cache in your MySQL database manually, e.g. for database profiling, execute the following command in your...
So you added a new callback to your model that (e.g.) caches some data when it is saved. Now you...