Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Ruby (http://www.programmingforums.org/forum63.html)
-   -   Won't Execute other Find_by_sql (http://www.programmingforums.org/showthread.php?t=10977)

SirBob1701 Aug 7th, 2006 8:46 AM

Won't Execute other Find_by_sql
 
Hey guys heres some code I broke it up because the find_by_sqls would only work like that but now they don't work at all. It appears after the first one the interpreter doesn't call any of the other functions. Is this normal how can I get it to call all the other functions?

:

        def find_others(id)
         
          #NEW NOTE: FOR SOME REASON IT WOULD NOT ALLOW MULTIPLE FIND_BY_SQL
          #IN ONE METHOD I MIGHT BE MISSING SOME KIND OF END BRAKE SO INSTEAD I
          #THE SQLS INTO METHODS
          # THE IFs THAT DO NOT ALLOW UNNEEDED HEADERS TO NOT BE DISPLAYED ARE IN THE VIEW
         
          @array = [] #setting up the empty set for comparison later in view
          @rdifferential = Rdifferential.find(:all, :conditions => ['vehicleID = ?', id])
          @tow = Tow.find(:all, :conditions => ['vehicleID = ?', id])
          @repair = Repair.find(:all, :conditions => ['vehicleID = ?', id])
          @driver = Driver.find(:all, :conditions => ['vehicleID = ?',id])
          oiled(id)
          inspect(id)
          braked(id)
          appear(id)
          treded(id)
         
    end
   
    def oiled(id)
        @oil = Oil.find_by_sql (["SELECT lastDate, lastMile, cost FROM oils WHERE vehicleID = ? AND lastDate = (SELECT MAX(lastDate) FROM oils WHERE vehicleID = ?)", id , id]);
    end
   
    def braked(id)
        @brake = Brake.find_by_sql (["SELECT lastdate, cost FROM brakes WHERE vehicleID = ? AND lastdate = (SELECT MAX(lastdate) FROM brakes WHERE vehicleID = ?)", id , id])
    end
   
    def inspect(id)
        @inspection = Inspection.find_by_sql (["SELECT month, last, over, cost FROM inspections WHERE vehicleID = ? AND last = (SELECT MAX(last) FROM inspections WHERE vehicleID = ?)", id , id])
    end
   
    def treded(id)
        @tred = Tred.find_by_sql (["SELECT FrontL, FrontR, BackL, BackR FROM treds WHERE vehicleID = ? AND tredID = (SELECT MAX(tredID) FROM treds WHERE vehicleID = ?)", id , id])           
    end
   
    def appear(id)
        @apperance = Apperance.find_by_sql (["SELECT exterior, interior, driverscab, trash, points FROM apperances WHERE vehicleID = ? AND appID = (SELECT MAX(appID) FROM apperances WHERE vehicleID = ?);", id , id])
    end


SirBob1701 Aug 7th, 2006 6:52 PM

Sorry forgot to reply that it was my dumbass that had code in the view so it thought i was passing an array instead of a single instance


All times are GMT -5. The time now is 9:42 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC