ruby on rails - pass variable through render -
i making nested form, done in railscasts , have problem render. in form have
<% form_for @question, :url => user_questions_path, :html => {:multipart => true} |f| %> <%= f.label :name %> <%= f.text_field :name, :class => "text_input" %> <%= f.label :description %> <%= f.text_area :description, :cols => "1", :rows => "1", :class => "textarea" %> <div id="reg"> <%= render :partial => "user_form", :f => f %> </div> ... <% end %> and in user_form file have
<% f.fields_for :user |builder| %> <%= builder.label :email %> <%= builder.text_field :email, :class => "text_input" %> <%= builder.label :password %> <%= builder.text_field :password, :class => "text_input" %> <%= builder.label :password_confirmation %> <%= builder.text_field :password_confirmation, :class => "text_input" %> <% builder.fields_for :user_profile, @question.user.user_profile || @question.user.build_user_profile |u| %> <%= u.label :secondname %> <%= u.text_field :secondname, :class => "text_input" %> <%= u.label :firstname %> <%= u.text_field :firstname, :class => "text_input" %> <% end %> <% end %> i have error in first line of partial
undefined local variable or method `f' for
what doing wrong?(i using rails 2.3, in cast rails 2 used too). in advance
i think may need change
<%= render :partial => "user_form", :f => f %> to 1 of following:
<%= render "user_form", :f => f %> <%= render :partial => "user_form", :locals => {:f => f} %>
Comments
Post a Comment