Ruby-on-Rails [SOLVED]: Rails selecting all columns Home › Forums › Frameworks › Ruby on Rails Tutorials › Ruby-on-Rails [SOLVED]: Rails selecting all columns Tagged: associations, rails-activerecord, ruby-on-rails Viewing 1 post (of 1 total) Author Posts January 2, 2018 at 5:52 am #246747 Cloudy PointKeymaster Question I have an Article model class with a one-to-many connection to the User model class Article < ApplicationRecord belongs_to :user end class User < ApplicationRecord has_many :articles end When I run article = Article.find(1) article.user.username The last statement loads the entire table. Selecting all columns is one of the performance’s evil. This is the Rails console output: User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]] But I want just the username column. Is there a way to do it using the same notation (model_instance.model_instance.column)? Author Posts Viewing 1 post (of 1 total) You must be logged in to reply to this topic.