I'm having this type of search:
values = ModelName.find(:all, :conditions => ['attr_id IN (SELECT attr_id FROM srv_type_attr WHERE id IN (?))', serv_objt_attr.collect(&:stya_id)])
Witch returns me an array of needed values:
[33458, 33438]
Next i need to check if record exists with select:
serv_objt_attr.select {|array| array.stya_id == values.collect(&:attr_id).uniq}
This is an example what i'm thinking off.
So how to do it with select, so he would walk through all values witch i'm getting from values.
I know that i could to something like
values.collect(&:attr_id).uniq do |val|
serv_objt_attr.select {|array| array.stya_id == val}
end
But i do not thing that this is a good option.
Ruby 1.8.7 Rails 2.3.4
Model.find(:all, :conditions => [...])isn't a statement you come across often. Normally you'd useModel.where(...)This might be relevant for those writing answers.valuesis an array containing integers. I'm a bit confused by your third and fourth code block, especiallyvalues.collect(&:attr_id)which is short forvalues.collect { |value| value.attr_id }. An integer doesn't have the methodattr_idas far as I know. What is happening here?