-
-
Notifications
You must be signed in to change notification settings - Fork 829
Milestone
Description
Ransack version: 4.3.0
Rails version: 7.2.2.1
Ruby version: 3.3.7
🧩 Problem
Searching through a two-level nested association is not working, even with ransackable_associations and ransackable_attributes explicitly defined as per the Ransack 4.3.0 documentation.
✅ Expected Behavior
Given the following model structure:
class Comment < ApplicationRecord
belongs_to :post
end
class Post < ApplicationRecord
belongs_to :user
end
class User < ApplicationRecord
# has attribute :email
end
I expect this query to work:
Comment.ransack(post_user_email_cont: "[email protected]").result
...and generate SQL similar to:
SELECT "comments".* FROM "comments"
INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"
INNER JOIN "users" ON "users"."id" = "posts"."user_id"
WHERE "users"."email" ILIKE '%[email protected]%'
❌ Actual Behavior
The search query returns no results, or an error, even when:
All associations are valid
souravforsycamore, kvsushma and manikandankrishnasamysycamore