rails/rails — Issue #3614: STI type column reader is not defined on ruby 1.8.7-p352 until you access the column directly
Author: jrafanie
Created: 2011-11-11 23:36:51+00:00
State: open

Using a vanilla app via rails new with rails 3.1.1 with ruby 1.8.7-p352: user.type raises a deprecation warning on ruby 1.8.7-p352 ((irb):1: warning: Object#type is deprecated; use Object#class) until I access the user's type column via user[:type], or read_attribute or manually create a new user.

This issue does not occur with ruby 1.9.2-p290.

It appears that since ruby 1.8.7 has a type method, we are not defining this type method early one and some other code path defines it later on although too late if I only ever go through the type reader.

Because 1.9.2 does not have this type column, my type reader method is defined in the earlier code path and everything works.

Any ideas where I should look in the code to propose a fix?

See this gist for a basic app and overview:
https://gist.github.com/1359653