我想仅在用户对象(@row)不为nil时才在用户列表中插入用户。如何在rjs模板中有条件地插入?
page.insert_html:bottom,:userlist, render(:partial =>“user”,:locals => {:user => @row,:myid => @ row.id})
非常感谢。
答案 0 :(得分:3)
你是如何在普通红宝石中做到的
if @row
page.insert_html(:bottom, :userlist, render(:partial => "user", :locals => { :user => @row, :myid => @row.id }))
end
或者如果你想要它在一行
page.insert_html(:bottom, :userlist, render(:partial => "user", :locals => { :user => @row, :myid => @row.id })) if @row
答案 1 :(得分:1)
page.insert_html :bottom, :userlist, render(:partial => "user", :locals => { :user => @row, :myid => @row.id }) unless @row.blank?