inheritance_column issues

hey all, I have a table like that: devices( id int(5) uid int(5) type varchar(5) )

this is my model:

class Rdevice < ActiveRecord::Base set_table_name "devices" end

for legacy reason I cannot change the column names. So I get this error when I do Rdevice.find :all

"ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'uuid'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Rdevice.inheritance_column to use another column for that information."

Any idea how I can fix it? I know there is a inheritance_column function to overwrite it but I couldn't get it to work.

thanx in advance

Pat

Brian Cowdery wrote:

Hi Patrick, so for your specific example...

hey all, I have a table like that: devices( id int(5) uid int(5) type varchar(5) )

Your model should look like this

class Rdevice < ActiveRecord::Base set_table_name "devices" set_inheritance_column :ruby_type

# getter for the "type" column def device_type   self[:type] end

# setter for the "type" column def device_type=(s)   self[:type] = s end end

Enjoy! -Brian

Hi Brian,

That's a nice solution to the issue, even I was stuck with the same issue. It solved the inheritence_column issue.

Thanks