Let's understand how to transfer data to our employee application using the RhoSync server.
First, update the query method in your source adapter company.rb
:
def query(params=nil) # TODO: Query your backend data source and assign the records # to a nested hash structure called @result. For example: @result = { "1" => {"name" => "Google"}, "2" => {"name" => "Microsoft"} } end
In @result
, we have hash of hashes where the hash key of the outer hash is the ID of each object (as described above in the query method). Each hash key in the inner hash represents an attribute of an individual object. Whatever value we store in @result
, the same values will be sync to device. Note that, all data types must be strings (so the hash values need to all be strings not integers). For example:
@result = { "1" => {"name" => "Google"}, "2" => {"name" => "Microsoft"} }
These values will be updated in the...