Kishore Mohan
Kishore Mohan

Reputation: 1060

simple_form_for partial file with same object

I am new to ruby on rails I am having a view which have partial file in that partial file also i have to render same object but iam getting error .

Here are my code

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: '[email protected]', 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 %>

I am getting error like

undefined local variable or method `f' for #  

Upvotes: 0

Views: 2054

Answers (2)

Lazarus Lazaridis
Lazarus Lazaridis

Reputation: 6029

Try this:

<%= render :partial=> other_fields, :object => @customer, :locals => {:f => f} %> 

Upvotes: 0

manoj
manoj

Reputation: 1675

<%= render :partial=> other_fields, :locals => {:f => f} %> 

Upvotes: 2

Related Questions