11 Replies Latest reply on Sep 3, 2013 9:17 AM by Mark Nongkhlaw

    App error: undefined method `update_attributes' for #<Array:0x4583618>

    Val Palhories

      Hello,

       

      I have a fixed Schema model and am trying to update a RHOM database row. I'm just trying to create a short little demo so the database structure may not make much sense. Please bare with me!

       

      My model looks as follows:

       

      class Item

        include Rhom::FixedSchema

        property :ServiceOrderID, :string

        property :ItemNumber, :string

        property :Description, :string

        property :QtyNeeded, :long

        property :QtyDelivered, :long

        index :by_ItemNumber, [:ItemNumber]

       

      I have the following method:

       

      def self.UpdateQtyOrdered (serviceorderid,itemnumber,qtydelivered)

            @item_row = Item.find(:all, :conditions =>{'ServiceOrderID'=>serviceorderid,'ItemNumber'=>itemnumber})

            if @item_row != nil

                @item_row.update_attributes({"QtyDelivered" => qtydelivered.to_i}) 

            end

      end

       

      I get the following when I inspect the @item_row variable from the Rhoelements debugger:

       

      @item_row[{:source_id=>40003, :object=>"146036996298588.12", :ServiceOrderID=>"SR22343", :ItemNumber=>"Burn Aids:57010", :Description=>"Burn Jel Unit Pack", :QtyNeeded=>"8", :QtyDelivered=>"0"}]

       

      The following is the log file entry:

       

      I 08/18/2013 06:58:25:075 0000053c           HttpServer| Process URI: '/app/Order/markitemdelivered'

      I 08/18/2013 06:58:25:075 0000053c                  APP| RHO serve: /app/Order/markitemdelivered

      I 08/18/2013 06:58:25:075 0000053c                  APP| Params: {"itemnumber"=>"Bandaids:0204", "serviceorderid"=>"SR22343", "sitename"=>"Lunchroom Cabinet", "customername"=>"DCT Solutions Group", "qtydelivered"=>"9"}

      I 08/18/2013 06:58:25:076 0000053c                  APP| App error: undefined method `update_attributes' for #<Array:0x4583618>

      E:/WorkSpace/Demo-POD/app/Item/item.rb:47:in `UpdateQtyOrdered'

      E:/WorkSpace/Demo-POD/app/Order/order_controller.rb:55:in `markitemdelivered'

      C:/MotorolaRhoMobileSuite2.2.1.13/ruby/lib/ruby/gems/1.9.1/gems/rhodes-3.5.1.13/lib/framework/rho/rhocontroller.rb:104:in `serve'

      C:/MotorolaRhoMobileSuite2.2.1.13/ruby/lib/ruby/gems/1.9.1/gems/rhodes-3.5.1.13/lib/framework/rho/rhoapplication.rb:248:in `serve'

      C:/MotorolaRhoMobileSuite2.2.1.13/ruby/lib/ruby/gems/1.9.1/gems/rhodes-3.5.1.13/lib/framework/rho/rho.rb:883:in `serve'

      I 08/18/2013 06:58:25:076 0000053c           HttpServer| GC Start.

      I 08/18/2013 06:58:25:077 0000053c           HttpServer| GC End.

       

      Note: If I perform the update via the following method it works just fine:

       

      def self.UpdateQtyOrderedSQL (serviceorderid,itemnumber,qtydelivered)

            require_source("Item")   

            database = Rho::RHO.get_src_db("Item")

            sql = "UPDATE Item SET QtyDelivered = " + qtydelivered + " WHERE ItemNumber = '" + itemnumber.to_s + "'"    

            database.execute_sql(sql) 

      end

       

      I'm sure it's something stupid! What am I missing here? I really would like to get update_attributes working!!

       

      Thanks.

       

      --- Val