For my classes
class User < ActiveRecord::Base
self.inheritance_column = :user_type
scope :customers, -> { where(user_type: '1') }
scope :freight_forwarders, -> { where(user_type: '2') }
end
class FreightForwarder < User
has_many :quotes, foreign_key: "ff_id"
end
class Customer < User
has_many :quotes, foreign_key: "ff_id"
end
[1] I am getting the following error, when I try to call User.customers
ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: '1'. This error is raised because the column 'user_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 User.inheritance_column to use another column for that information.
[2] when I try to call Customer.all the query runs like this,
SELECT "users".* FROM "users" WHERE "users"."user_type" IN (0)
I am not able to understand why it is '0' it should be '1'.