0
I’m having difficulty searching with has_many interactions in ruby on Rails. Goal is to search all vehicles that have no fines type 'guy'... The problem is that the query I made still returns several vehicles with the type 'guy'. I’m trying to perform the search like this:
veiculos = Veiculo.joins(:multas).where.not(multas: { tipo: 'cara' }).group('veiculos.id')
Where am I going wrong?
Can you explain what the code does? It’s the solution to the question posed?
– João Martins
The variable vehicles is an Active Record that picks up all models Vehicle that has the model Fine with the column "type" with the face value. The code picks up the table Vehicles, makes a Join table with the table Fines and of those takes all the fines that the column type are "expensive"
– Davis Roberto