有没有办法将index
传递给activeadmin的嵌套形式partial?我拥有的代码如下:
<% variant.has_many :variant_currencies, allow_destroy: true, heading: false, new_record: 'Add new price modifier' do |variant_currency| %>
<% variant_currency.template.render partial: 'variant-currency-form', locals: { variant_currency: variant_currency, index: '??? how to pass it here ???' } %>
<% end %>
通常,如果我有一个迭代,我会像这样传递index
:<% Post.each_with_index do |post, index| %>
,但是我如何告诉activeadmin,我希望在has_many
语句中有index
呢?谢谢您的支持。
发布于 2017-08-21 13:12:13
你可以用一个老式的柜台..。
<% counter = 0 %>
<% variant.has_many :variant_currencies, allow_destroy: true, heading: false, new_record: 'Add new price modifier' do |variant_currency| %>
<% variant_currency.template.render partial: 'variant-currency-form', locals: { variant_currency: variant_currency, index: counter.to_s } %>
<% counter += 1 %>
<% end %>
https://stackoverflow.com/questions/45797690
复制相似问题