Ruby on Rails
Sunday, February 27, 2011
On Mon, Feb 28, 2011 at 3:53 AM, Erwin <yves_dufour@mac.com> wrote:
I was happy too quickly ...
I actually need to produce a structure like this ( to be used with
Mongoid DB criteria )
{ "$in" => [tags[0]], "$in" =>[tags[1]] , ....}
you can't. a hash should have unique keys.
I may have to use a json structure ?
On 27 fév, 20:16, Erwin <yves_duf...@mac.com> 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
>
> I tried this :
>
> myHash = {}
> tags.each do |tag|
> h = {"$in" => [tag]}
> myHash.merge!(h)
> end
>
> but the merge! is only changing the value ... (as the key is always
> the same ..)
> (there is no += as with Array class ...)
>
> thanks for your feedback
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment