Possible Duplicate:
Calling a Function From a String With the Function's 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 get this to call properly? I'm guessing the syntax is probably similar to creating a dynamic method.
You could try using send
send("#{col_str}_greater_than".to_sym, 30)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With