【发布时间】:2011-12-03 09:06:21
【问题描述】:
可能重复:
Calling a Function From a String With the Function's Name in Ruby
我想做这样的事情:
def self.greater_than(col_str='events')
self."#{col_str}"_greater_than(30) # search logic scope method
end
我怎样才能让它正确调用?我猜语法可能类似于创建动态方法。
【问题讨论】:
标签: ruby-on-rails ruby variables dynamic methods