0

We can render a partial using

<%= render "shared/header", attr1: 1, attr2: 2 %>

or using the following method

<%= render partial: "shared/header", locals: {attr1: 1, attr2: 2} %>

Only the difference i have found is the way attributes are passed to the partial.

Heir Of Knowledge
  • 617
  • 1
  • 6
  • 13

1 Answers1

0

There is no big difference between them. I prefer the first example. But sometimes u should render this partial within concrete layout. And u should type <%= render partial: "shared/header", layout: 'something'%> . Also note that explicitly specifying :partial is required when passing additional options such as :layout. So it depends on situation. If u want to render just partial without any extra options then just use first example or use second one if u want to pass some extra options like layout

CR7
  • 1,056
  • 1
  • 8
  • 18