Skip to content

Commit

Permalink
adding how to prevent n+1 queries to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
orlando committed Feb 24, 2016
1 parent aafd0fd commit 1999868
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ If you don't want fancy JS features, all you have to do is just switch to `:inpu
<%= f.input :images, as: :file, input_html: { multiple: true } %>
```

### Preventing n+1 queries when loading attachinary associations

You can eager load attachinary associations.

For example, I have a `user` model that has `photo` and `avatar` as attachments.

```rb
# user.rb
has_attachment :avatar
has_attachments :photos

# users_controller.rb
User.includes(:avatar_files, :photo_files).all
```

## Conventions

Expand Down

0 comments on commit 1999868

Please sign in to comment.