ruby on rails - Includes with only certain attributes -
is there way like:
book.includes(authors: {only: :first_name})
i want attribute, not whole author model.
nope, can't. if don't want load data can load books , run separate query on authors bring names alone:
books = book.where(something_here) author_ids = books.map(&:author_id) author_names = author.where(id: author_ids).pluck(:id, :first_name)
Comments
Post a Comment