-1
class Anketum < ActiveRecord::Base
has_one :user
class << self
def search(params)
self.scope :h, :conditions => {:height => params[:height]}
#scope :w, :conditions => {:width => params[:width]}
self.h if params[:height]
end
end
end
我需要创建多个范围取决于PARAMS [:XXX]目前多个范围轨
原因不起作用......奇怪的'SELECT“anketa”。* FROM“anketa”' – 2012-02-13 17:07:15
你的db表也称为“anketa”?如果不是,你的设置有些问题。 – coreyward 2012-02-13 18:21:26
你在哪个Rails版本上?我假设你使用'scope'而不是'named_scope'。 – coreyward 2012-02-13 18:22:13