instance method reselect

Ruby on Rails 7.2.3

Since v6.0.6

Available in: v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

reselect(*args)

Allows you to change a previously set select statement.

Post.select(:title, :body)
# SELECT `posts`.`title`, `posts`.`body` FROM `posts`

Post.select(:title, :body).reselect(:created_at)
# SELECT `posts`.`created_at` FROM `posts`

This is short-hand for unscope(:select).select(fields). Note that we’re unscoping the entire select statement.

Parameters

args rest
Source
# File activerecord/lib/active_record/relation/query_methods.rb, line 534
    def reselect(*args)
      check_if_method_has_arguments!(__callee__, args)
      args = process_select_args(args)
      spawn.reselect!(*args)
    end

Defined in activerecord/lib/active_record/relation/query_methods.rb line 534 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::QueryMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close