8 Replies Latest reply on Jun 27, 2012 4:26 AM by Oesia Project

    Error dosync parameters

      Hello,

       

      We are trying to pass parameters between terminal and Rhoconnect. When we execute the Synchronization with Rhodes example,

       

      SyncEngine.dosync(false, "param1=12&param2=abc")

       

      We get an error on Rhoconnect console:

       

      wrong number of arguments (1 for 0)

       

      The Rhoconnect function is,

       

      def query(params)   

          puts params   

      end

       

      Do you know what’s happen?

       

      Jordi.

        • Re: Error dosync parameters

          Check out this Google Group post.

          Seems like a similar problem:

          https://groups.google.com/forum/?fromgroups#!topic/rhomobile/5r_3aXON4Ns

           

          Hope it helps!

            • Re: Error dosync parameters

              Hello,

               

              That post is not usefull for us because it's about other problem (we have sinatra 1.3.2 version).

               

              We observed that when we execute do_sync function with params, the server receives a GET query with our params. That's right. But we don't know how to get it in the rhoconnect query function.

               

              10.226.12.20 - - [18/Jun/2012 17:26:51] "GET /application?client_id=1b8f920889e84d0cbbf45daad26a6edc&p_size=2000&version=3&source_name=Product&param1=12&param2=abc HTTP/1.1" 200 162 0.2969

               

              Is there a API function to get params?

               

              Thanks.

               

              Oesia.

                • Re: Error dosync parameters

                  So what you want to do is get the params from within your query function?

                    • Re: Error dosync parameters

                      Yes, we want to do something like this:

                       

                      def query(params=nil)

                          param1 = get the url param 'param1'

                          param2 = get the url param 'param2'

                      end

                        • Re: Error dosync parameters

                          Yes, we want to do something like this:

                           

                          def query(params=nil)

                              param1 = get the url param 'param1'

                              param2 = get the url param 'param2'

                          end

                          Your params are in the "params" argument passed into the method, so you can access them like:

                           

                          def query(params=nil)
                            param1 = params['param1']
                            param2 = params['param2']
                          end
                          

                           

                          You mentioned earlier you got an error "wrong number of arguments (1 for 0)", is there a stacktrace in the log for this or more information you could provide?  The "query" source adapter method does accept a params argument (as you can see from the boilerplate code) so it should not raise this exception.

                            • Re: Error dosync parameters

                              Hello Lars,

                               

                              It dosen't work because params argument is null. I'll copy-past our log...

                               

                              [10:10:20 AM 2012-06-19] SourceAdapter raised query exception: undefined method `[]' for nil:NilClass

                              [10:10:20 AM 2012-06-19] D:/Rhomobile/workspace/storeserver/sources/product.rb:15:in `query'

                              D:/Rhomobile/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhoconnect-3.1.1/lib/rhoconnect/source_adapter.rb:82:in `do_query'

                              D:/Rhomobile/RhoStudio/ruby/lib/ruby/gems/1.8/gems/rhoconnect-3.1.1/lib/rhoconnect/source_sync.rb:387:in `_read'

                                ...

                              226.12.20 - - [19/Jun/2012 10:10:20] "GET /application?client_id=1b8f920889e84d0cbbf45daad26a6edc&p_size=2000&version=3&source_name=Product&param1=12&param2=abc HTTP/1.1" 200 165 0.1404

                               

                              Oesia.