ruby-on-rails

Invalid rendering array with locals and as by PropsTemplate gem


I use gem props_template and I need to render array with some partial and additional local, I use something like

json.array! @orders, partial: ['shared/order', locals: {employee: current_employee}, as: :order] do
end

and inside of partial

json.iid order.iid

But it returns list of the same iids from one of the orders (with any partial attributes - all elements in response will be the same from one of the elements)

[{ 'iid' => 1 }, { 'iid' => 1 }, { 'iid' => 1 }]

if remove locals - everything works fine and iids are different

I forked repository, added test for such case, and it fails because renders the same elements

I have 2 questions


Solution

  • There was bug in gem, it is fixed in commit.

    Right now partials can be correctly rendered with locals variables