ruby on rails - How to create { x = y | y = z | z = 0 } block dynamically from hash? -


Although the context is probably irrelevant, I am using Chewy gem to filter elastic search results using this code Send me (property_ads [0],: or) == val.map (and: to_i)):

  scope = scope.filter {(Send ('facet_properties'). Send ('facet_properties'). Send (Property_Ads [1],:) or == val.map (and: to_i))}  

I'm looking for a way , property_ids [1] , etc., separate from and loop through each element in property_ids Or will not be a fixed length in the actual use of property_ids in real use.

Definitely not at all what your structure looks like or exactly what you are trying to achieve Are you trying to do something like this?

  vals = val.map (and: to_i) prop_hash = hash [property_ids.map {| Prop | [Sahara, vals]}] # Optionally by prop_hash = property_ids.each_with_object ({}) {| Sahara, obj | Obj [prop] = vals} scope.filter (facet_properties: {prop_hash}). Since filter_mode (: or)  

Since chewy is a #filter_mode method for setting conditions such that it seems that This should work for you.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -