Giving object's send-method an other method with block
metaprogramming, ruby, ruby-on-rails
Solution
You should try something like that :
Beer.all.send(:sort_by) {|b| b.name}
Problem
This one works: ``` Beer.all.send(:sort) ``` and also it works with block: ``` Beer.all.sort_by{|b| b.name} Beer.all.sort_by(&:name) ``` But when I give a executable block to send-method like this: ``` Beer.all.send(:sort_by{|b| b.name}) Beer.all.send(:sort_by(&:name)) ``` I get syntax error. Is there any alternative way in Ruby to give an executable block to send-method?