I tried this code:
voiplogs = where(['data > ? AND data < ?', start_date, end_date]).group_by(&:cli)
it's works, but how add also sort by :cli
Tanks to all Fabio
I tried this code:
voiplogs = where(['data > ? AND data < ?', start_date, end_date]).group_by(&:cli)
it's works, but how add also sort by :cli
Tanks to all Fabio
I tried this code:
voiplogs = where([‘data > ? AND data < ?’, start_date,
end_date]).group_by(&:cli)
voiplogs = where([‘data > ? AND data < ?’, start_date, end_date]).order(‘cli ASC’).group_by(&:cli)
In ruby 1.9.2,
...group_by(&:cli).sort
Otherwise, you can't because hashes are unordered by nature. You can sort the keys and then access the hash using the sorted keys. Or, you can use ActiveSupport::OrderedHash, and try to figure out how to initialize it when you have a Hash.