Ruby/Rails Features and Patterns

Flashcard 4 of 6

Do you know a more succinct way to write this?

<%= render partial: "product", collection: @products %>

You can just pass your collection directly to render:

<%= render @products %>

By the way, Rails determines which partial to render for a given object by sending the to_partial_path message to it. ActiveRecord objects define this already, but you can override it if you like. You can also define this method on non-AR objects.

Return to Flashcard Results