View Rails
# index.html.erb <h1>Products</h1> <%= render(@products) || content_tag(:p, 'There are no products available.') %> # Equivalent to `render :partial => "product", @collection => @products
render(@products) will return nil when @products empty.
ruby
puts "no objects" if @collection.blank? @collection.each do |item|
source share