Skip to content


when Picky::Convenience will mess up the ids #115

bennacer860 opened this Issue · 4 comments

3 participants


After trying to integrate Picky with a rails application, and i am running into an issue:

ruby-1.9.2-p180 :006 > "kenya", 1000000 
 => >|2013-06-27 15:34:46|0.000117|kenya                                             |       1|   0| 1| 
ruby-1.9.2-p180 :007 > r.ids
 => [30] 
ruby-1.9.2-p180 :008 > r.extend Picky::Convenience 
 => >|2013-06-27 15:35:26|0.000117|kenya                                             |       1|   0| 1| 
ruby-1.9.2-p180 :009 > r.ids
NoMethodError: undefined method `[]' for Allocation([:myths, 0.0, 1, [[:title, "kenya", "kenya"]], [30]]):Picky::Query::Allocation
    from /home/rbennacer/.rvm/gems/ruby-1.9.2-p180@mythopedia/gems/picky-client-4.15.1/lib/picky-client/convenience.rb:21:in `block in ids'
    from (__FORWARDING__):1:in `each'
    from (__FORWARDING__):1:in `each'
    from /home/rbennacer/.rvm/gems/ruby-1.9.2-p180@mythopedia/gems/picky-client-4.15.1/lib/picky-client/convenience.rb:21:in `ids'
    from (irb):9
    from /home/rbennacer/.rvm/gems/ruby-1.9.2-p180@mythopedia/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
    from /home/rbennacer/.rvm/gems/ruby-1.9.2-p180@mythopedia/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
    from /home/rbennacer/.rvm/gems/ruby-1.9.2-p180@mythopedia/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

i have noticed that in picky / client / lib / picky-client / convenience.rb the allocations are treated an Array instead of a Picky::Query::Allocation. Am i wrong on this?


Thank you so much for your quick response, but I am not sure to understand your response, can you be more specific and explain the error that is thrown in my example.


It means that you should not extend the object you have with Picky::Convenience, because that module is designed for a different use case.


Hi Rafik,

The module is for use in the client where you get a Hash with the results. Since getting the ids out of the hash can be a bit cumbersome to write, I provide a comfortable "convenient" module that you can extend the Hash with.

The Results already provide an ids method – you don't need to extend the results. So in your results, simply call

r = "kenya", 1000000


@floere floere closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.