module ActiveRecord::AttributeMethods
def accessed_fields
end
@posts = Post.select(:id, :title, :author_id, :updated_at)
def index
class PostsController < ActionController::Base
Which allows you to quickly change your code to:
end
end
p @posts.first.accessed_fields
def print_accessed_fields
private
end
@posts = Post.all
def index
after_action :print_accessed_fields, only: :index
class PostsController < ActionController::Base
For example:
all of the fields on the model).
required fields can be an easy performance win (assuming you aren't using
need to be selected. For performance critical pages, selecting only the
model. This can be useful in development mode to determine which fields
Returns the name of all database fields which have been read from this
def accessed_fields @attributes.accessed end