I am building a query but I need to pass the parameters that I am sending to the model to be used in the query, the problem is that I can not make the query accept the parameters within the select, this is my query:
def self.reporte_inventario_total(params)
query = select("(SELECT Ruta FROM Rutas WHERE IdRutas = :rutaId or :rutaId = '') AS Ruta,
ISNULL((SELECT S.Stock/PP.PzaXCja AS INT FROM stockhistorico S LEFT JOIN ProductosXPzas PP ON S.Articulo=PP.Producto WHERE S.Articulo=Productos.Clave AND S.RutaId = :rutaId or :rutaId = '' AND fecha = :fechaDiaO or :fechaDiaO = ''),0) AS StockCajas,
ISNULL((SELECT S.Stock%PP.PzaXCja AS INT FROM stockhistorico S LEFT JOIN ProductosXPzas PP ON S.Articulo=PP.Producto WHERE S.Articulo=Productos.Clave AND S.RutaId = :rutaId or :rutaId = '' AND fecha = :fechaDiaO or :fechaDiaO = ''),0) AS StockPiezas,
Productos.Clave, Productos.Producto, Productos.CodBarras,Productos.Sector", ({rutaId: params[:search],fechaDiaO: params[:fechaDiaO]}))
end
and this is the error that I get
unsupported: Hash