50 Experience
0 Lessons Completed
0 Questions Solved


I have a table Operations with two columns referenced to Accounts. One column is called debit_id and other credit_id. Model looks like

    belongs_to :debit,  class_name: :Account, optional: true
    belongs_to :credit, class_name: :Account, optional: true

So I want to include reference to Ledger model that is referenced in Accounts model from Operations. I don't have direct account_id in my Operations I need some workaraound as far as it's impossible to do smth like that

has_one :ledger, through: :debit
has_one :ledger, through: :credit

Is it possible at all in Rails?