I am making a query to find all those products that are not related to a table called Stock where the "Path" field within the Stock table is different from the id that I am passing through the URL. I'm doing it in the following way:
@productos = Producto.joins('left outer join stock on productos.Clave=stock.Articulo')
.select('productos.*,stock.Articulo')
.where('stock.ruta != ? AND productos.Status = ?', params[:id], "A")
The problem with this query is that it is showing me the repeated products, depending on the quantity of stocks to which this product is associated, how can I solve it?