When storing floating-point numbers such as prices or totals in an SQL database, always use a DECIMAL column. Never...

When deploying an application with "cap deploy" by default [1] you only deploy your code but do not run migrations...

ActiveRecord gives you the :include option to load records and their associations in a fixed number of queries. This is...

User.active.to_sql Rails 2 Use either the Edge Rider or fake_arel gem to get #to_sql backported...

There is a nasty bug in all version of Rails 2 and some versions of Rails 3.x where two...

At times, it might be unavoidable to have different CSS rules for Internet Explorer than for sane browsers. Using Sass...

makandra dev

The information in this card is only relevant for Rails 2.3-era apps. This note gives a quick introduction into...

Note that you cannot currently use Ruby 1.9.2 with Rails 2 applications that use RSpec, so don't upgrade if...

Specify these gem versions in your Gemfile: gem 'cucumber', '~> 1.3.0' gem 'cucumber-rails', '= 0.3.2' # max version for Rails 2

makandra dev
github.com

The shell variable PS1 holds your bash prompt. You might want to change it to serve your needs best. Here...

After updating your RubyGems, you will probably not be able to run Capistrano any more, but receive an error similar...

songit.posterous.com

RubyGems 1.6.0 has undergone some changes which may cause Rails 2.x applications to break with an error like this...

makandra dev
innig.net

If you want to get a deep understanding of how closures, blocks, procs & lambdas in Ruby work, check out the...

en.wikipedia.org

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.

See our new comprehensive guide for upgrading every Rails 2 version ever.

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:

Sometimes it is useful to define a named scope by implementing a static method with the scope's name on...

makandra dev

Given group size If you would like to split a Ruby array into pairs of two, you can use the...

You cannot use Array#join on an array of strings where some strings are html_safe and others are not...

Update: This trick probably isn't very useful anymore in Ruby 2.x. The Ruby GC has improved a lot...

imperialviolet.org

In January this year (2010), Gmail switched to using HTTPS for everything by default. Previously it had been introduced as...

See our new comprehensive guide to upgrading every Rails 2 version ever.