Я делаю вложенную форму, как это было сделано в railscasts, и у вас возникли проблемы с рендерингом. В моей форме я естьпередать переменную через визуализацию
<% form_for @question, :url => user_questions_path, :html => {:multipart => true} do |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 %>
и в моем файле user_form У меня есть
<% f.fields_for :user do |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 do |u| %>
<%= u.label :secondname %>
<%= u.text_field :secondname, :class => "text_input" %>
<%= u.label :firstname %>
<%= u.text_field :firstname, :class => "text_input" %>
<% end %>
<% end %>
У меня есть ошибка в первой строке частичной
неопределенной локальной переменной или метода `F» для
Что я делаю неправильно? (Я использую рельсы 2.3, но в литых рельсах 2 тоже использовались). Заранее спасибо
Вы отсутствуют ': местные => {...}'. Еще два совета: 1) используйте '[: user, @question]' как ресурс, и вы можете пропустить опцию: url. 2) Вызовите 'fields_for' вне частичного пользователя, что улучшает модульность. – tokland