Skip to content

Commit

Permalink
[ci skip] Add skip_preload to README
Browse files Browse the repository at this point in the history
  • Loading branch information
OuYangJinTing committed Jul 20, 2020
1 parent 7a5f73e commit 330b33d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -44,6 +44,11 @@ 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 330b33d

Please sign in to comment.