Skip to content

Commit

Permalink
[ci skip] Add skip_preload to README and CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
OuYangJinTing committed Jul 20, 2020
1 parent 7a5f73e commit b642a4c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

## master

- [PR [#33](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/34)] Feature skip_preload, allow turn automatic preload off ([@OuYangJinTing][])

## 0.3.1 (2020-07-10)

- [PR [#33](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/33)] Don't do merge if there is nothing to merge ([@Earendil95][])
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -44,6 +44,12 @@ ArLazyPreload.config.auto_preload = true

After that there is no need to call `#lazy_preload` on the association, everything would be loaded lazily.

If you want to turn automatic preload off for a specific record, you can call `.skip_preload` before any associations method:

```ruby
users.first.skip_preload.posts # => SELECT * FROM posts WHERE user_id = ?
```

## Installation

Add this line to your application's Gemfile, and you're all set:
Expand Down
4 changes: 2 additions & 2 deletions spec/ar_lazy_preload/skip_preload_spec.rb
Expand Up @@ -33,8 +33,8 @@

it "loads excluded association" do
subject.load.last.skip_preload.posts.to_a
id_concat = subject[0..-2].map(&:id).join(', ')
question_concat = (['?'] * (subject.size - 1)).join(', ')
id_concat = subject[0..-2].map(&:id).join(", ")
question_concat = (["?"] * (subject.size - 1)).join(", ")
expect do
subject.first.posts.to_a
end.to make_database_queries(
Expand Down

0 comments on commit b642a4c

Please sign in to comment.