Passing complex key in ruby client (2.0 Preview 3)
I think this is more of a Ruby question than Couchbase 2.0 but I am having trouble passing a complex key to a view.
What I want to see is:
http://127.0.0.1:8092/default/_design/message/_view/summary_by_sender?group_level=2&startkey=[%221111111111%22]&endkey=[%221111111111%22,{}]
I have been unable to produce this. The closest I have been able to get is:
startkey=%22%5B%5C%221111111111%5C%22%5D%22&endkey=%22%5B%5C%221111111111%5C%22%2C+%7B%7D%5D%22
which, of course is:
startkey="[\"1111111111\"]"&endkey="[\"1111111111\", {}]"
Obviously the quotes around the complex key aren't helping, neither are the escaped quotes around the sender.
I would think this is the proper way to pass the JSON along:
def self.summary_by_sender(sender) results = design.summary_by_sender(:group_level => 2, :startkey => [sender].as_json, :endkey => [sender,{}].as_json).fetch results.map { |result| new({:key => result['key'], :value => result['value']}) } end
Help? I've pretty much googled everywhere and haven't found a proper Ruby example of passing a JSON array to startkey/endkey.