Skip to content

Commit 78bb3e6

Browse files
committed
A better deferrable example for a controller context
1 parent 63c9583 commit 78bb3e6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

README.textile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ This concept is quite useful in an MVC context, allowing the controller to fetch
9191
def index
9292
# No blocking, executes in the background, yields a deferrable result.
9393
#
94-
@posts = Posts.published.find(:all, :defer => true )
94+
@posts = Posts.published.find(:all, :defer => true ) # Slow, push to the background
95+
@visitors = Site.visitors.recent # Snappy
96+
# You don't want to do this. Try to not invoke methods on deferred results right away
97+
# to minimize potential blocking.
98+
@posts.any?
9599
end
96100

97101
end

0 commit comments

Comments
 (0)