一千萬個為什麽

搜索

局部變量沒有通過渲染傳遞給部分模板?

我似乎無法將變量傳遞給rails(2.3.5)中的部分模板。我的代碼如下;

在主視圖.html.erb文件中:


     payment_form, :t => "test" } %>

並在_payment.html.erb文件中:


produces a wrong number of arguments (0 for 1) error. The payment_form object is being passed to the partial as f without any problems. I've tried a number of variations on the above syntax (e.g. :locals => {:f => payment_form, :t => "test" } without success. I presume I'm doing something pretty basic wrong but just can't see it.

最佳答案

這可能是因為t()是用於I18n的保留視圖輔助方法。只需將其重命名為更具描述性的內容即可

轉載註明原文: 局部變量沒有通過渲染傳遞給部分模板?