Open MoAI522 opened 6 hours ago
I think it occurs by line below: https://github.com/active-hash/active_hash/blob/0b3701c54cfcd195423885cd5df70e6959a3a2c0/lib/associations/associations.rb#L18
join_model is treated without identifying whether it is ActiveRecord or ActiveHash. But I couldn't find the way to fix it.
Describe the bug
I can't retrieve ActiveRecord records from ActiveHash object when the ActiveHash is related to the ActiveRecord through another ActiveHash.
To Reproduce
books
table below.ActiveRecord::Schema[7.2].define(version: 2024_09_21_030534) do create_table "books", force: :cascade do |t| t.string "title" t.integer "author_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false end end
test/fixtures/books.yml
one: title: MyString author_id: 1
two: title: MyString author_id: 1
Expected Behavior
Returns all Book records.(They are all have author_id=1, and the author relates to country 1.)
Actual Behavior
The output is below.
My environment
OS: Ubuntsu 20.04.3(WSL) Ruby version: ruby 3.2.4 (2024-04-23 revision af471c0e01) [x86_64-linux] Rails version: 7.2.1 active-hash version: 3.3.1
The rails uses sqlite3 as database. sqlite3 version: 3.37.2 2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5dalt1