Possible duplicate:Calling a function from a string with the function name in Ruby
I want to do something like this:
def self.greater_than(col_str='events') self."#{col_str}"_greater_than(30) # search logic scope method end
How can I make it call correctly? I guess the syntax is probably similar to creating a dynamic method.
You can try using send
send
send("#{col_str}_greater_than".to_sym, 30)
try it
def self.greater_than(col_str='events') self.send("#{col_str}_greater_than", 30) # search logic scope method end