I have two instance values: @a, and @b, there are hash-like….
(will explain on pseudo examples)
For example in @a i have:
*Field1 | Field2 | Field3*
CONTITECH | CT942K1 | 123
CONTITECH | CT722K1 | 123
ATE | AB2123 | 123
in @b i have:
CONTITECH | CT942K1 | 456
BREMBO | TE132 | 123
How to do that @c = @a – @b will contain only values which are not in @b?
For example @c = @a – @b will contain:
CONTITECH | CT722K1 | 123
ATE | AB2123 | 123
So only if 2 field are same, i must delete from @a same value from @b…
If don’t clear by examples, write in comments…. What i need is just delete from @a all same by (field1 and field2) entries in @b…
How to do this?
if this will help: code:
this is @b (@articles):
@articles = Article.find(:all, :conditions => ["ART_ID in (?) ", @search.map(&:ARL_ART_ID)])
and @a (@non_original):
@non_original = []
nr_condition = "*" + art_nr.to_s.gsub(/[^0-9A-Za-z]/, '').upcase + "*"
if art_nr.length > 3
art = search_not_oem(art_nr)
@search = CrossList.find(:all, :conditions => ['MATCH (cross_value) AGAINST (? IN BOOLEAN MODE)', nr_condition])
if @search.present?
@prlist = PriceList.where("id IN (?)", @search.map(&:price_list_id))
if @prlist.present?
@prlist.each do |p|
#@all_supp = Supplier.all
#if @all_supp.find{|item| item.SUP_BRAND.gsub(/[^0-9A-Za-z]/, '').include?(p.brand.gsub(/[^0-9A-Za-z]/, '').upcase)} && art.present?
# logger.warn("!!!!!! if")
#else
@non_original << p
#end
end
end
end
end
@non_original
what i need is to @res = @non_original – @articles, sure they have different fields, but with same data…
Try this:
That should put into
@resall objects from@non_original, except for those whosefield1andfield2match those of any element in@articles. The objects in@reswill be the same type as@non_original– that is,PriceList.