SELECT * FROM DeptTemp_development.permits p, DeptTemp_development.permit_dept_locations pdl, DeptTemp_development.dept_locations dl WHERE pdl.permit_id= p.id and pdl.dept_location_id = dl.id
Now here is what I wrote in ruby to try and get that same result:
def totalCost @permits = Permit.find(:all) @pdl = @permits.each do |perm| @pdl << PermitDeptLocation.find_by_permit_id(perm.id) end @deptloc =  @pdl.each do |dep| @deptloc << DeptLocation.find_all_by_id(dep.dept_location_id) end @deptloc.fee_daily end
So this seems legit to me until i got an error for the dep.dept_location_id line, so i did i puts pdl.inspect to see what was going on. For some odd reason it's get 3 exact permits I want but also puts in 6 nils in the array. I have a told of 9 permits in my database, and 6 of those shouldn't get through the part :
@pdl << PermitDeptLocation.find_by_permit_id(perm.id)
Any suggestions? Thx!