ActiveModel search by association
问题 I've seen similar questions but nothing exactly like mine. I apologize if this is a duplicate - if it is, please refer me to answer(s). I need to search orders by customer names, and the link between the two is users. Here are my models: class Customer < ApplicationRecord belongs_to :user end class User < ApplicationRecord has_one :customer has_many :orders end class Order < ApplicationRecord belongs_to :user end I'm trying to search using: @orders = Order.joins(:user).joins(:customers).where