Skip to content

Class not recognized as MTI class #4

@manuelmeurer

Description

@manuelmeurer

Unfortunately my AdminUser class is not recognized as a MTI class. :(
I'm running Rails 4.2.10 and this is my setup:

ActiveRecord::Migration.create_table :users do |t|
  t.string :first_name, :last_name
  t.timestamps null: false
end

ActiveRecord::Migration.create_table :admin_users, inherits: :users do |t|
  t.text :roles, array: true, default: [], null: false
end
# db/structure.rb
CREATE TABLE users (
    id integer NOT NULL,
    first_name character varying,
    last_name character varying,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
);

CREATE TABLE admin_users (
    roles text[] DEFAULT '{}'::text[] NOT NULL
)
INHERITS (users);
# app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end

# app/models/user.rb
class User < ApplicationRecord
end

class AdminUser < User
end

When I check AdminUser.mti_type_column and AdminUser.tableoid_column on the console, they are both nil, which they shouldn't be according to the specs.
What can I do to further help debugging this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions