我有下一个代码:
文章/ _form.html.haml
- cat = Post::CATEGORIES.map { |c| [t(c, scope: :post_categories), c] }
= f.input :category, collection: cat
= f.input :subject, input_html: { class: 'input-block-level' }
= f.input :body, input_html: { rows: 5, class: 'ctrlenter input-block-level expanding' }
= link_to "#", class: 'smiley', role: 'add_smiley', tabidex: 4 do
%i.icon.icon-smile
смайлы
= smiles_helper '#post_body'
.form-horizontal
= f.input :tag_list, input_html: { class: 'input-block-level' }
- if (current_user.paid? && current_user.moderated_group_ids.include?(@group.id)) || moderator?
= f.input :comments_disabled, inline_label: true, label: false
.attachments
= f.simple_fields_for :attachments do |af|
= render "attachments/#{af.object.asset_type.underscore}", :f => af
.poll{style: "display: none;"}
%h1 "Новый опрос"
= f.simple_fields_for :poll do |post|
= render "polls/poll_fields", f: post
轮询/ poll_fields.html.haml
= f.error_messages header_message: nil
= f.input :question, disabled: !@poll.editable?(current_user), input_html: { class: 'input-block-level' }
= f.input :results_hidden, as: :boolean, inline_label: 'Скрыть результаты до окончания опроса', label: false
= f.input :from_date, as: :datetime, input_html: { class: 'poll_date' }
= f.input :to_date, as: :datetime, input_html: { class: 'poll_date' }
%h3#poll-items Варианты ответа (не больше пяти)
.item_index
= f.simple_fields_for :poll_items do |poll|
= render template: "polls/poll_item_fields", f: poll
= link_to_add_association 'Добавить еще вариант', f, :poll_items,
{ 'data-association-insertion-method' => 'before',
'data-association-insertion-traversal' => 'next' }
轮询/ poll_item_fields.html.haml
.poll_row
.poll_item
= f.input :answer, input_html: { class: 'ctrlenter expanding' }, label: false, placeholder: 'Введите вариант ответа'
= link_to_remove_association "удалить", f, { wrapper_class: 'poll_item' }
显示错误:显示第3行引发的... / views / polls / poll_item_fields.html.haml:
#<#:0xbe2d1a2c>
的未定义局部变量或方法`f'我如何正确地将变量f传递给polls / poll_item_fields.html.haml?
答案 0 :(得分:0)
render template: "polls/poll_item_fields", f: poll
试
render "polls/poll_item_fields", f: poll