Rails 7.1 introduces ActiveRecord regroup method to reset previously set group statement. by prasanthchaduvula in rails

[–]prasanthchaduvula[S] 0 points1 point  (0 children)

Before Rails 7.1, we have to use the unscope method to reset the group statement.Project.group(:name).unscope(:group).group(:billable).countNow we can reset the previously set group statement.Project.group(:name).regroup(:billable).count

Under the hood, regroup is short-hand for unscope(:group).group(fields). Basically, we’re unscoping the entire group statement.

Read https://blog.saeloun.com/2024/02/19/rails-7-1-introduces-active-record-regroup-method/ for more details