There is a model Game like this. The Game has date and point columns.
class Game < Sequel::Model
plugin :json_serializer
end
When I use a aggregation function it returns a error.
Game.select(Sequel.lit('max(point) as max_point')).group(:date).to_json
#=>`NoMethodError: undefined method `max_point'`
I can avoid the error by defining a method max_point in Game model.
def max_point
@values[:max_point]
end
I don't want to define a new method every time when I use a aggregation function. Is there a recommended way to solve the problem like this?