我有这4个模型通过has_many,belongs_to相互关联。基本是2(食谱,配料)。另外2个商店基于前两个存储额外的信息。 class Recipe
has_many :ingredients, :through => :prescriptions
has_many :prescriptions
end
class Ingredient
has_many
def self.search(search)
if search
find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
end
end
我将如何修改这个功能,所以它首先检查是否有在name领域search参数完全匹配,如果没有精确匹配,返回匹配,而不是LIKE ?查询的结果?