class A< ActiveRecord::Base
def self.select_name
--------不知道怎么写
end
end
class B< ActiveRecord::Base
end
class C< ActiveRecord::Base
end
A:
card:string
is_b:0 or 1
B:
name:string
card:string
C:
realname:string
card:string
实现@test=A.select_name(params[:name])
通过A从B/C表中找到name为params[:name]的模糊搜索(card为关联字段,is_b为判断是否为B表)
万恶的表结构!大神请帮忙!谢谢大家啦!