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

agileweboperations.com

User Stories should describe what a user wants the system to do. Purely technical tasks should usually be implemented as...

The Edge Rider gem will define a method collect_ids on your ActiveRecord models, scopes, integer scalars and collections, which...

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...

The Basic Authentication header encodes username and password. Effectively, it's just Base64 plus a "Basic" prefix.

blog.plataformatec.com.br

It is common in Rails 3.0 applications that you want to provide default views for a group of controllers. Let...

apidock.com

Note: ActiveRecord::Base#becomes has a lot of quirks and inconsistent behavior. You probably want to use ActiveType.cast instead.

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

makandra dev

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

Sometimes you can make your life easier by not allowing a record attribute to be changed after the record was...

ActiveRecord comes with a method touch which sets the updated_at timestamp to the current time. Unfortunately it also runs...

Add deprecation warnings and their solution or link to available solutions. Global access to Rake DSL methods is deprecated. Please...

Pie sometimes does not properly redraw elements upon changes. This often happens when the change comes from somewhere further up...

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 can find ActiveRecord models by using a Range as its conditions: User.scoped(:conditions => { :id => 3..5 }) This will generate...

You will occasionally need to clean out your database while keeping the schema intact, e.g. when someone inserted data in...

When you click a link or a press a button on a Selenium-controlled browser, the call will return control...

When you set both a record's association and that association's foreign key attribute, Rails does not realize you...

MySQL's MIN and MAX functions are for aggregations only. This will not work and produce an error:

makandra dev

If you use a form (or form fields) multiple times inside one view, Rails will generate the same id attributes...

Note: For PostgreSQL you should use advisory locks. For MySQL we still recommend the solution in this card.

makandra dev
wiki.debian.org

This note is a reminder that there is something called AppArmor that could cause weird errors ("File not found", "Can...