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

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

To test whether two arrays have the same elements regardless of order, you can use the =~ matcher in RSpec < 2.11...

makandra dev

Sometimes you want to run a command forever, e.g. to compile a haml to html file on the console. Use...