Thanks fred .. found how to do it.... there is a specific criteria for it ( I did not fully understand when reading it the first time...)
Criteria#all_in: Matches if all values provided match, useful for doing exact matches on arrays. so writing : criteria.all_in(:tags => tags ).to_a did it ... I'll try to give an eye to the underlaying Mongoid ruby code in charge of doing that .... On 27 fév, 21:49, Frederick Cheung <[email protected]> wrote: > On Feb 27, 7:56 pm, Erwin <[email protected]> wrote: > > > this is to be used with MongoID as a criteria > > > criteria.where(:tags => { "$in" => [tags[0]], "$in" > > =>[tags[1]] }).to_a > > > any suggestion with json structure ? > > You can't repeat keys in a json hash either. What are you actually > trying to do? > > Fred > > > > > > > > > > > On 27 fév, 19:47, Frederick Cheung <[email protected]> wrote: > > > > On Feb 27, 6:29 pm, Erwin <[email protected]> wrote: > > > > > given an Arra tags[] > > > > > I need to produce a resulting Hash as following .. > > > > > { "$in" => [tags[0]], "$in" =>[tags[1], ...} > > > > > in which the key should be always the same and the value being an > > > > Array > > > > By definition, a hash stores a single value for a given key. The > > > closest you'll get is to make the value an array of all the things for > > > the key in question. > > > > Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

