User Stories should describe what a user wants the system to do. Purely technical tasks should usually be implemented as...
ActiveRecord gives you the :include option to load records and their associations in a fixed number of queries. This is...
Type looking a little flabby? Overweight? Want to give it a kick in the pants? Take a look at some...
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:
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...
Have a backup. Stop MySQL: sudo service mysql stop Move (or copy) your mysql directory. If you want /mnt/mysql to...
When you use the send_file method to send a local file to the browser, you can save resources on...
A check if two date or time ranges A and B overlap needs to cover a lot of cases:
Note: Consider not doing this. Use form models or vanilla methods instead. The :conditions option for Rails associations cannot take...
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...
Update: This trick probably isn't very useful anymore in Ruby 2.x. The Ruby GC has improved a lot...
The following Sass will do the trick: button, input[type="reset"], input[type="button"], input[type="submit"], input[type="file...
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...
Deadlocks only occur if two transactions in separate threads compete for the same rows in the database. They usually (but...
If you need to do calculations inside the database and can not use Ruby objects you may run into problems...
Occasionally some complex query must be processed on the database because building thousands of Ruby objects is impracticable.
CONCAT('foo', 'bar', NULL) = NULL the NULL always wins in MySQL. If you would rather treat NULL as...
Use this MySQL command to show further info about a table: SHOW CREATE TABLE tags; This will output a table...
The ancestry gem allows you to easily use tree structures in your Rails application. There is one somewhat unobvious pitfall...