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

When you use will_paginage to paginate a scope, and you want to obtain the total number of records matched...

alfajango.com

There is a problem with AJAX response handling for Rails 3 remote links and forms in Internet Explorer. This problem...

For clarity and traceability, your commit messages should include the ID and title of the Pivotal Tracker story you're...

You most likely never want to do this. But if you do: Model.update_all({:id => new_id}, {:id => old_id...

To only run the next two migrations: rake db:migrate STEP=2 To revert the previous two migrations:

Use this scope: class Stick named_scope :shuffled, lambda { last_record = last { :conditions => [ 'id >= ?', rand(last_record.id) ] } if last_record }

CONCAT('foo', 'bar', NULL) = NULL the NULL always wins in MySQL. If you would rather treat NULL as...

Use this MySQL command to show further info about a table: SHOW CREATE TABLE tags; This will output a table...

apidock.com

You can now add an :inverse_of option to has_one, has_many and belongs_to associations.... Without :inverse_of...

Be careful when using params.merge as params is a HashWithIndifferentAccess. Why? Usually this should not be an issue but it...

Be careful when memoizing a method that returns a scope, e.g.: def variants scoped(:conditions => { :name => name }) end memoize :variants...

When using form_for you can give the form's target URL either as a string or an array: