Method: ActiveRecord::QueryMethods#reselect

Defined in:
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.



325
326
327
328
# File 'lib/active_record/relation/query_methods.rb', line 325

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