0 Replies Latest reply on Jul 21, 2013 9:38 AM by Val Palhories

    Undefined method find_by_sql????

    Val Palhories



      Can anyone tell me what would cause the following error:  Undefined method find_by_sql?


      Here's what the simulator is saying:


      Error: undefined method 'find_by_sql' for Message:Class


      E:/WorkSpace/ScoutMobile/app/Message/message.rb:52:in `GetMessages'

      E:/WorkSpace/ScoutMobile/app/Message/message.rb:61:in `GetMessageUser'

      E:/WorkSpace/ScoutMobile/app/MainMenu/main_menu_controller.rb:24:in `index'


      Lines 52 and 61 from the message model are below in red:


      def self.GetMessages()  

            sql = "SELECT * FROM Message"

            sql = sql + " WHERE ActiveIND='true'"

            sql = sql + " AND (ScheduledSendDateTime IS NULL OR Date('now') >= Date(ScheduledSendDateTime))"

            sql = sql + " ORDER BY MessageDateTime"

            return Message.find_by_sql(sql)



        def self.GetMessage(rowId)

            return ModelHelper.Get(Message,rowId)



        def self.GetMessageUser()

            userid = Settings.GetLoggedInUser()

           return Message.GetMessages().select{|msg| !msg.MessageRecipient.nil? && msg.MessageRecipient.UserID==userid.to_s && msg.MessageRecipient.ReadDateTime.nil?}



      I can confirm that the table does in fact exist and that there is data in the table as shown in the image below:


      This does work sometimes ... so I'm not certain what's going on!! Any thoughts on what I might check?




      --- Val