I try Searching polymorphic relation with namespaces.
Models
class Logistic::Order < ActiveRecord::Base
belongs_to :origin, polymorphic: true
belongs_to :destination, polymorphic: true
endclass Logistic::Location < ActiveRecord::Base
endclass Logistic::PickupPoint < ActiveRecord::Base
endclass Logistic::Warehouse < ActiveRecord::Base
end
I try:
Logistic::Order.ransack(origin_of_Location_type_name_cont: 'test')
and got the error:
NameError: uninitialized constant Kernel::Location from (irb):40
because he could not get the namespace of location
Also probe with:
Logistic::Order.ransack(origin_of_Logistic_Location_type_name_cont: 'test')
and got the error:
NameError: uninitialized constant Logistic::Order::Origin from (irb):41
Now I do not know what else to try
The 3 classes contain "name" attribute, my idea is to be able to make a query by making a join against Location, PickupPoint and Warehouse classes
My English isn't well, sorry
I try with:
Logistic::Order.ransack("destination_of_Logistic::Location_type_name_cont" => 'Maria Jose Paoli')
and works!
Thanks.
Most helpful comment
I try with:
Logistic::Order.ransack("destination_of_Logistic::Location_type_name_cont" => 'Maria Jose Paoli')and works!
Thanks.