I know I have seen this before and I can't remember how to fix it or find where I saw how to fix it:
def product_matcher(item) product =  if !item.blank? product = self.products.where(:id => item.id).first else product = self.products.where(:id => token.id).first end product end
It seems wrong to me to first set the variable to an array, then inside the scope of the each to set product to the result of the query and then at the end of the method have the variable return the product. Since Ruby doesn't have explicit types my belief is that you don't even need the
product =  and since the result of a Ruby method is always to return you more than likely don't even need product at the end. However, due to scoping the output would be encapsulated inside the each block and the method would ultimately return nothing when called. How do I improve this?