Thursday, June 25, 2009

"Type" column in legacy databases

Rails will look for the STI classes which you don't need in this case. The workaround is:-

class EventLog < ActiveRecord::Base

set_table_name 'EventLog'


def self.inheritance_column
nil
end

def category
read_attribute :type
end

end

Suppress the STI by overriding inheritance column.
Define a method that reads type otherwise type will always return you the class