Note: Consider not doing this. Use form models or vanilla methods instead. The :conditions option for Rails associations cannot take...

alfajango.com

The difference between .bind(), .live(), and .delegate() is not always apparent. Having a clear understanding of all the differences, though...

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

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

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

opensoul.org

I love ETags, but there’s something that annoys me: most implementations revolve around pulling a record out of a...

Find-as-you-type boxes are usually built by observing changes in a text field, and querying the server via...

kernel.org

Git allows you to do a binary search across commits to hunt down the commit that introduced a bug.

alistapart.com

I was recently confronted with the task of creating a two-column liquid layout with a header and footer in...

In order to redirect all requests from redirecting-host.com to desired-host.com while keeping path and query params unchanged, change your Apache...

In regular expressions you can use the zero-width pattern \b to match the beginning or end of a word...

makandra dev

If you need to export data from MySQL to a CSV, you can profit from really fast built-in methods...

makandra dev

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

gurge.com

How to write to the db 27,000 times in 24 seconds instead of 9 minutes.

When you eagerly load an association list using the .include option, and at the same time have a .where on...

If you want to find out whether a Class object is directly inheriting from another class, use superclass: ActiveRecord::RecordNotFound.super...

snippets.dzone.com

These two models can be used to access the posts and associated comments of a WordPress database.

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

prototypejs.org

jQuery's selector engine, live()-like event handlers, pixel-perfect layout measuring.

When a has_many association basically serves to store a list of associated strings (tags, categories, ...), it can be convenient...

Note that this card is very old. You might want to use ActiveType for your auto-coerced virtual attributes instead...