0
votes

I am trying to build a multi page form based on Wicked for a system that we plan on using. However, after i added the 3rd form page, that is used to fill a second table in the database i get the error listed below. I already tried adding and removing <% end %> tags at the end but without succes. can anyone help me out?

/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 %>

and the stepscontroller:

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
1
You have 2 blocks in fields_for without endmikdiet
Try to indent your code and you will seemikdiet

1 Answers

0
votes

Just add 2 end before closing of fieldset

  <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 %>