Method: ActiveRecord::QueryMethods#reselect

Defined in:
activerecord/lib/active_record/relation/query_methods.rb

#reselect(*args) ⇒ Object

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.



532
533
534
535
536
# File 'activerecord/lib/active_record/relation/query_methods.rb', line 532

def reselect(*args)
  check_if_method_has_arguments!(__callee__, args)
  args = process_select_args(args)
  spawn.reselect!(*args)
end