renders_none :empty slot to handle fallback rendering on empty collection #2008
-
Thinking about the need/addition of a #the partial way
render(partial: "product", collection: @products) || render("empty") # current implementation
# in view
if @products.size.zero?
render Product::EmptyComponent.new
else
render ProductComponent.with_collection(@products, user: current_user)
end # proposed solution
# in view
render ProductComponent.with_collection(@products, user: current_user)
# inside product_component.rb
renders_none :none, EmptyComponent |
Beta Was this translation helpful? Give feedback.
Answered by
joelhawksley
Jun 11, 2025
Replies: 1 comment
-
I think your existing solution is what I would recommend ❤️ |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
joelhawksley
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think your existing solution is what I would recommend ❤️