Local variable not displaying correctly in foundation's reveal partials
我的视图中包含以下代码:
1 2 3 4 5 | <% @post_comments.each do |comment| %> <%= render partial:"flags/flag_comment", locals: { comment: comment } %> <% end %> |
这是我的部分内容:
1 2 3 4 5 6 7 8 9 10 | <%= simple_form_for [comment, @flag] do |f| %> <%= f.input :reason %> <%= f.button :submit %> <% end %> Flag |
但是,局部变量'comment'的设置不正确。
如果将
如果有任何影响,我正在使用Zurb的基础创建"显示"。
有人可以解释我要怎么做吗?
那是因为对于所有局部div
数据展示将查找具有
如果您有多个具有相同ID的div,则数据展示将选择具有匹配ID的第一个div。
因此,每次单击标志链接时,您将获得相同的ID
要解决此问题,我建议为每个评论使用不同的ID,
例如:您可以执行以下操作
1 2 3 | <%= content_tag :div, :id =>"flagComment_#{comment.id} ..... %> ... <% end %> |
上面每次都会设置不同的ID \\。并且您将在