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.

Ariana Habbaba
Check out this Google Group

Check out this Google Group post.

Seems like a similar problem:

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

Hope it helps!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Oesia Project
Hello,That post is not

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.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
So what you want to do is get

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

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Oesia Project
Yes, we want to do something

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

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Darryn Campbell
Yes, we want to do something

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.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Oesia Project
Hello Lars,It dosen't work

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.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
I think your client code is

I think your client code is incorrect.  It needs to contain a "query" parameter.  So instead of:

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

it should be:

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

Then in your adapter you can access the params with:

params['param1']

#=> 12

params['param2']

#=> "abc"

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Oesia Project
Thanks Lars,It works !!

Thanks Lars,

It works !!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments