结束还是没有结束?期待 keyword_end

End or no end? expecting keyword_end

我正在尝试为我们计划使用的系统构建一个基于 Wicked 的多页面表单。 但是,在我添加了用于在数据库中填写第二个 table 的第三个表单页面后,我得到了下面列出的错误。 我已经尝试在末尾添加和删除 <% end %> 标签,但没有成功。谁能帮帮我?

/home/supervisor/Rubyrails/Werkvergunning/app/views/enquirys/steps/measurements.html.erb:45: syntax error, unexpected keyword_ensure, expecting keyword_end /home/supervisor/Rubyrails/Werkvergunning/app/views/enquirys/steps/measurements.html.erb:47: syntax error, unexpected end-of-input, expecting keyword_end

Rails.root: /home/supervisor/Rubyrails/Werkvergunning Application Trace | Framework Trace | Full Trace

app/views/enquirys/steps/measurements.html.erb:45: syntax error, unexpected keyword_ensure, expecting keyword_end app/views/enquirys/steps/measurements.html.erb:47: syntax error, unexpected end-of-input, expecting keyword_end app/controllers/enquirys/steps_controller.rb:7:in `show'

measurements.erb.html:

<%= form_for @enquiry, method: :put, url: wizard_path do |f| %>
  <% if f.object.errors.any? %>
    <div class="error_messages">
      <% f.object.errors.full_messages.each do |error| %>
        <p><%= error %></p>
      <% end %>
    </div>
  <% end %>

  <fieldset>
    <legend>Maatregelen</legend>
       <%= f.fields_for :enquiry_measures do |enquiry_measures| %>
                                <%= enquiry_measures.fields_for :measure do |measures| %>
    <div>
      <%= f.label :Maatregel %>
      <br />
      <%= collection_select(:measure, :enquiry_id, Enquiry.all, :id, :measurement) %>
     <%# http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select -%>
    </div>
     <div>
      <%= f.label :Gereed %>
      <br />
      <%= enquiry_measures.text_field :done %>
    </div>

    <div>
      <%= f.label :Verantwoordelijke %>
      <br />
      <%= enquiry_measures.text_field :responsible %>
    </div>

    <div>
      <%= f.label :Benodigd %>
      <br />
      <%= enquiry_measures.text_field :needed %>
    </div>       

    <div>
      <%= f.submit 'Next Step' %>
    </div>
  </fieldset>
<% end %>

和步骤控制器:

class Enquirys::StepsController < ApplicationController
include Wicked::Wizard
  steps *Enquiry.form_steps

  def show
    @enquiry = Enquiry.find(params[:enquiry_id])
    render_wizard
  end

  def update
    @enquiry = Enquiry.find(params[:enquiry_id])
    @enquiry.update(enquiry_params(step))
    render_wizard @enquiry
  end

  private

  def enquiry_params(step)
    permitted_attributes = case step
                           when "basic"
                             [:Reference, :Location, :Description]
                           when "when"
                             [:Amount, :Date]
                           when "measurements"
                            [:responsible]
                           end

    params.require(:enquiry).permit(permitted_attributes).merge(form_step: step)
  end

end

只需在字段集关闭前添加2个end

  <fieldset>
    <legend>Maatregelen</legend>
    <%= f.fields_for :enquiry_measures do |enquiry_measures| %>
      <%= enquiry_measures.fields_for :measure do |measures| %>
        <div>
          <%= f.label :Maatregel %>

          # .....

      <% end %> <%# end of enquiry_measures.fields_for :measure %>
    <% end %> <%# end of f.fields_for :enquiry_measures %>
  </fieldset>
<% end %>