0
我有下面的类方法,并想知道是否有更漂亮(更ruby-ist)的方法来解决这个问题。'case'里面的where子句
def self.of_users_that(type)
case type
when "registered"
type = 1
when "apologized"
type = 2
end
Subscription.where(:regoption_id => type)
end
谢谢!
重用变量使用不同的值是一个可怕的做法,这是可悲的,因为这是非常普遍的(并且很容易修复......)。 – tokland 2013-03-07 11:30:50