I have models:
class Model < ActiveRecord::Base
has_many :model2
end
class Model2 < ActiveRecord::Base
belongs_to :model
belongs_to :model3
end
class Model3 < ActiveRecord::Base
has_many :model2
end
Model3 has field in db label. How could I find Model by Model3 label?
With “joins” you can filter results according to linked models
This will create only on db call, so it is very efficient. But joins can create duplicates when there is more than one way from model to model3. If this is possible then you need to add