Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do find() with includes() in Rails 3

I'm trying to do something like this, but it's not working. How would I do this in Rails 3?

Student.find(12).includes(:teacher) 
like image 608
99miles Avatar asked Oct 15 '10 15:10

99miles


1 Answers

You just have to be more careful with the order of the methods in this case:

Student.includes(:teacher).find(12) 
like image 163
Robert Speicher Avatar answered Sep 25 '22 02:09

Robert Speicher