Class instance variables not inherited "activerecord-import" rails

78 views Asked by At

I'm using activerecord-import (1.0.3). There is a way to override the sequence_name of a model in order to have import taking it into account:

class A < ApplicationRecord
  self.abstract_class = true
  self.sequence_name = "my_new_seq"
end

However when I do:

class B < A
  ...
end

B.import! data # it uses B default sequence_name

The way to get the right sequence_name used is to specify it once again:

class B < A
  self.sequence_name = "my_new_seq"
end

B.import! data # uses B good sequence_name

How can I get this value to be passed to subclasses?

Response

Class A is an abstract class. sequence_name should be defined the following way:

class A < ApplicationRecord
  self.abstract_class = true
  
  class << self
    def sequence_name
      "my_new_seq"
    end
  end
 
end
0

There are 0 answers