method
references
v4.0.2 -
Show latest stable
- Class:
ActiveRecord::QueryMethods
references(*args)public
Used to indicate that an association is referenced by an SQL string, and should therefore be JOINed in any query rather than loaded separately.
User.includes(:posts).where("posts.name = 'foo'") # => Doesn't JOIN the posts table, resulting in an error. User.includes(:posts).where("posts.name = 'foo'").references(:posts) # => Query now knows the string references posts, so adds a JOIN