This project is archived and is in readonly mode.

#188 ✓stale
Joshua J. Born

Single table inheritance bug only in production environment

Reported by Joshua J. Born | May 13th, 2008 @ 10:32 PM

With ActiveRecord 2.0.2, define the following classes.

class A < ActiveRecord::Base

class B < A

class C < B

Implement all three with single table inheritance. Create several instances of B and of C and save them in the database.

Call B.find(:all) in a controller list action.

If a development environment is loaded, then B.find(:all) will always return just objects of class B. Set a breakpoint on B.find(:all) in a debugger to verify this.

If a production environment is loaded, then the first time B.find(:all) is run it will return just objects of class B. However, on subsequent calls to B.find(:all), ActiveRecord returns objects of class C as well. This was checked with a debugger breaking as soon as B.find(:all) was called.

Loading a production environment in the console and running B.find(:all) multiple times seems to work correctly. This bug only occurs when called from within a controller.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

Shared Ticket Bins

Referenced by