activerecord-hackery / ransack

Object-based searching.
https://activerecord-hackery.github.io/ransack/
MIT License
5.67k stars 803 forks source link

Search Deep nested associations #1020

Closed artoodeeto closed 5 years ago

artoodeeto commented 5 years ago

Hello, Ransack team I just wanted to ask if ransack support this deeply nested query.

@search = Spree::WorkorderProductWorkstep.ransack(params[:q])

@search.result.includes(product_workstep: [:workstep],  workorder: [:product, denture_design: [:denture_design_spec], order: [:user]])

On our WorkorderProductWorkstep we set the ransackable_associations like:

// WorkorderProductWorkstep model
belongs_to :product_workstep, class_name: 'Spree::ProductWorkstep'

self.whitelisted_ransackable_associations = ['product_workstep']

this association search is working upto this part. <%#= f.search_field :product_workstep_name_cont %>

but when we add the associated workstep table like: <%#= f.search_field :product_workstep_workstep_name_cont %> //workstep is table we get an error no explicit hash even though we added an association on ProductWorkstep like:

// ProductWorkstep model
belongs_to :workstep, class_name: 'Spree::Workstep'
self.whitelisted_ransackable_associations = ['workstep']

ransack version 1.4.1 rails version 4.2.6 ruby version 2.3.6

artoodeeto commented 5 years ago

btw also i also read #358 and is it possible to search up to the users? thank you again.

bharathiraja252 commented 3 years ago

@artoodeeto Did you get the solution for this? I am facing the same