Skip to content

Instantly share code, notes, and snippets.

@roushkaman
roushkaman / gist:4278259
Created December 13, 2012 17:50
Есть парочка проблем и вопросов: 1.не могу заставить работать как хелпер 2.как делать исключение? 3.и где установить limit, так как везде он получаеться не определенным методом?
def self.similar(current_product)
semilars = self.where(:part_id => current_product.part_id, :model_id => current_product.model_id)
if semilars.count < 5
semilars |= self.where(:model_id => current_product.model_id)
if semilars.count < 5
sem = semilars | self.all
else
semilars
end
end