0

我是 ruby​​ on rails 的新手,我有一个视图,该视图在该部分文件中有部分文件,我也必须渲染相同的对象,但我收到错误。

这是我的代码

app/view/customer/_form.html.erb
 <%= simple_form_for(@customer) do |f| %> 
 <%= f.input :first_name, placeholder: 'First Name', label: 'Customer First Name' %>
 <%= f.input :last_name, placeholder: 'Last name', label: 'Customer Last Name' %>
 <%= f.input :email, placeholder: 'user@domain.com', label: 'Customer Email' %>
<%= render :partial=> other_fields,:f => f %>   
<%end%>

app/views/customer/_other_fields.html.erb

<%= f.input :user_name, label: 'User Name' %>
<%= f.input :password, label: 'Password' %>
<%= f.input :password_confirmation, :required => true %>

我收到类似的错误

undefined local variable or method `f' for #  
4

2 回答 2

2
<%= render :partial=> other_fields, :locals => {:f => f} %> 
于 2013-04-26T14:12:05.477 回答
0

尝试这个:

<%= render :partial=> other_fields, :object => @customer, :locals => {:f => f} %> 
于 2013-04-26T14:33:36.153 回答