instance method
regroup
Ruby on Rails 7.2.3
Since v7.1.6Signature
regroup(*args)
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.
Parameters
-
argsrest
Source
# File activerecord/lib/active_record/relation/query_methods.rb, line 586
def regroup(*args)
check_if_method_has_arguments!(__callee__, args)
spawn.regroup!(*args)
end
Defined in activerecord/lib/active_record/relation/query_methods.rb line 586
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::QueryMethods