activerecord - Rails: How to make has_many :through association work with Single Table Inheritance -


so in current project have article model can have different kinds of transactions. has 1 main transaction, under circumstances can have multiple sub-transactions.

until set this:

class article < activerecord::base   has_one :transaction, inverse_of: :article   has_many :partial_transactions, through: :transaction, source_type: 'multiplefixedpricetransaction', source: 'partialfixedpricetransaction', inverse_of: :articles end  class transaction < activerecord::base   belongs_to :article, inverse_of: :transaction # gets inherited kinds of transaction subclasses end  class multiplefixedpricetransaction < transaction   has_many :children, class_name: 'partialfixedpricetransaction', foreign_key: 'parent_id', inverse_of: :parent end  class partialfixedpricetransaction < transaction   belongs_to :parent, class_name: 'multiplefixedpricetransaction', inverse_of: :children   belongs_to :article, inverse_of: :partial_transactions # overwriting inheritance end 

now set errors like

activerecord::reflection::throughreflection#foreign_key delegated source_reflection.foreign_key, source_reflection nil:  #<activerecord::reflection::throughreflection:0x00000009bcc3f8 @macro=:has_many, @name=:partial_transactions, @options={:through=>:transaction, :source_type=>"multiplefixedpricetransaction", :source=>"partialfixedpricetransaction", :inverse_of=>:articles, :extend=>[]}, @active_record=article(id: integer ... 

by way, experimented lot source , source_type parameters , ones there examples. don't know them.

so, how can make work? how association set correctly?

thank you.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -