I'm trying to pass the foreign key from one view to another using partial render. However there is a problem in passing the local variable because only the last record get to be displayed.
我正在尝试使用部分渲染将外键从一个视图传递到另一个视图。但是传递局部变量存在问题,因为只显示最后一条记录。
Gist link: https://gist.github.com/ReemAlattas/5d08b0b60fc890540c7b
要点链接:https://gist.github.com/ReemAlattas/5d08b0b60fc890540c7b
Thanks in advance for your help!
在此先感谢您的帮助!
2 个解决方案
#1
0
In the _select.html.erb
file you should fix this row (previously used @p_id seems to be nil):
在_select.html.erb文件中你应该修复这一行(之前使用的@p_id似乎是零):
<% @kpis.each do |kpi| if kpi.plan_id == p_id %>
and in index.html.erb
you are passing to the partial a symbol :p_id
against the p_id
value, let replace it with:
并在index.html.erb中传递一个符号:p_id对p_id值,请将其替换为:
<%= render :partial => "kpis/select", locals: {plan_id: p_id} %>
#2
0
Try this
尝试这个
<% @kpis.each do |kpi| if kpi.plan_id == plan_id %>
#1
0
In the _select.html.erb
file you should fix this row (previously used @p_id seems to be nil):
在_select.html.erb文件中你应该修复这一行(之前使用的@p_id似乎是零):
<% @kpis.each do |kpi| if kpi.plan_id == p_id %>
and in index.html.erb
you are passing to the partial a symbol :p_id
against the p_id
value, let replace it with:
并在index.html.erb中传递一个符号:p_id对p_id值,请将其替换为:
<%= render :partial => "kpis/select", locals: {plan_id: p_id} %>
#2
0
Try this
尝试这个
<% @kpis.each do |kpi| if kpi.plan_id == plan_id %>