Skip to content
Browse files

Mention the case that `render` will return nil if given `:collection`…

… is nil or empty when rendering partial.
  • Loading branch information...
1 parent 5b86e8f commit 3ddbaf955e45eed15662e2f141b75dc0df63c1b0 @sikachu sikachu committed Nov 21, 2010
Showing with 5 additions and 0 deletions.
  1. +5 −0 actionpack/lib/action_view/partials.rb
View
5 actionpack/lib/action_view/partials.rb
@@ -75,6 +75,11 @@ module ActionView
#
# <%= render :partial => "ad", :collection => @advertisements, :spacer_template => "ad_divider" %>
#
+ # If the given <tt>:collection</tt> is nil or empty, <tt>render</tt> will return nil. This will allow you
+ # to specify a text which will displayed instead by using this form:
+ #
+ # <%= render(:partial => "ad", :collection => @advertisements) || "There's no ad to be displayed" %>
+ #
# NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also
# just keep domain objects, like Active Records, in there.
#

0 comments on commit 3ddbaf9

Please sign in to comment.
Something went wrong with that request. Please try again.