Issue
I'm using Rails 5. I have a model with a has_many relation ...
class Book
has_many :references, :autosave => true, :dependent => :destroy
When querying for the entity,
book = Book.find(params[:id])
what do I need to add so that the has_many relation entities are also included?
Solution
You can use includes method for eager loading:
Book.includes(:references).find(params[:id])
Answered By - demir Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.