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

Don't insert table rows in a Rails database migration. This will break tests that expect that database to be...

Occasionally some complex query must be processed on the database because building thousands of Ruby objects is impracticable.

Plugins (and gems) are typically tested using a complete sample rails application that lives in the spec folder of the...

web.archive.org

This step tests whether a given select option comes preselected in the HTML. There is another step to test that...

This is non-trivial because you need to fake event objects and require different code for different browsers. Luckily, there...