method
regroup
v8.1.1 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
regroup(*args)public
Allows you to change a previously set group statement.
Post.group(:title, :body) # SELECT `posts`.`*` FROM `posts` GROUP BY `posts`.`title`, `posts`.`body` Post.group(:title, :body).regroup(:title) # SELECT `posts`.`*` FROM `posts` GROUP BY `posts`.`title`
This is short-hand for unscope(:group).group(fields). Note that we’re unscoping the entire group statement.