在SQL中应该是这样的:
SELECT * FROM `categories_description_old` WHERE ((`categories_description` = '') OR (`categories_name` = '') OR (`categories_heading_title` = ''))
我的(丑陋的)解决方案:
conditions = [:categories_name, :categories_heading_title, :categories_description]
b = table_categories_description_old.filter(conditions.pop => "")
conditions.each do |m|
b = b.or(m => "")
end
有没有更好的方法来链接或条件?
filter(false)
,否则条件不会被检查。 - brauliobo