method

regroup

Importance_1
v7.2.3 - Show latest stable - 0 notes - 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.

Show source
Register or log in to add new notes.