2016-05-03 15 views
-1

私はレール上では少し新しく、Webアプリケーション用のネストモデルに取り組んでいます。ステップが割り当てられた目標を持っているRuby On Railsでエラーが発生しました:構文エラー、予期せぬkeyword_ensure、入力の終了を期待しています

私は、ネストされた目標や手順でネストされたフォームの作成に取り組んでいるが、私はあなたがエラーに

「構文エラー、予期しないkeyword_ensure、入力終了を期待」

<% form_for @goal do |goal_form| %> 
    <div> 
    <%= goal_form.label :Goal, 'Goal:' %> 
    <%= goal_form.text_field :Goal %> 
    </div> 
    <div> 
    <%= goal_form.label :Description, 'Description:' %> 
    <%= goal_form.text_area :Description %> 
    </div> 
    <div> 
    <%= goal_form.label :Date, 'Date:' %> 
    <%= goal_form.date_select :Date %> 
    </div> 
    <div> 
    <%= goal_form.label :DueDate, 'DueDate:' %> 
    <%= goal_form.date_select :DueDate %> 
    </div> 

    <!-- Here we call fields_for on the project_form builder instance. 
     The block is called for each member of the tasks collection. --> 
    <% goal_form.fields_for :steps do |step_form| %> 
     <p> 
     <div class="field"> 
      <%= step_form.label :requirement %><br> 
      <%= step_form.text_field :requirement %> 
     </div> 

     <div class="field"> 
      <%= step_form.label :completionTime %><br> 
      <%= step_form.number_field :completionTime %> 
     </div> 

     <% unless step_form.object.new_record? %> 
      <div> 
      <%= step_form.label :_delete, 'Remove:' %> 
      <%= step_form.check_box :_delete %> 
      </div> 
     <% end %> 
     </p> 

    <% end %> 
<% end %> 

<div class="actions"> 
    <%= goal_form.submit %> 
</div> 

<% end %> 

答えて

1

を取得しています余分な<% end %>を追加し、フォームが<%= form ..... %>ない<% form .... %>

これを使用して上記のコードを交換してくださいする必要があります。

<%= form_for @goal do |goal_form| %> 
    <div> 
    <%= goal_form.label :Goal, 'Goal:' %> 
    <%= goal_form.text_field :Goal %> 
    </div> 
    <div> 
    <%= goal_form.label :Description, 'Description:' %> 
    <%= goal_form.text_area :Description %> 
    </div> 
    <div> 
    <%= goal_form.label :Date, 'Date:' %> 
    <%= goal_form.date_select :Date %> 
    </div> 
    <div> 
    <%= goal_form.label :DueDate, 'DueDate:' %> 
    <%= goal_form.date_select :DueDate %> 
    </div> 

    <!-- Here we call fields_for on the project_form builder instance. 
     The block is called for each member of the tasks collection. --> 
    <% goal_form.fields_for :steps do |step_form| %> 
    <p> 
    <div class="field"> 
     <%= step_form.label :requirement %><br> 
     <%= step_form.text_field :requirement %> 
    </div> 

    <div class="field"> 
     <%= step_form.label :completionTime %><br> 
     <%= step_form.number_field :completionTime %> 
    </div> 

    <% unless step_form.object.new_record? %> 
     <div> 
     <%= step_form.label :_delete, 'Remove:' %> 
     <%= step_form.check_box :_delete %> 
     </div> 
    <% end %> 
    </p> 

    <% end %> 
    <div class="actions"> 
    <%= goal_form.submit %> 
    </div> 
<% end %> 
+0

ありがとうございました! – Frenchy

+0

あなたは大歓迎です! – HashRocket

0
<%= form_for @goal do |goal_form| %> 
    <div> 
    <%= goal_form.label :Goal, 'Goal:' %> 
    <%= goal_form.text_field :Goal %> 
    </div> 
    <div> 
    <%= goal_form.label :Description, 'Description:' %> 
    <%= goal_form.text_area :Description %> 
    </div> 
    <div> 
    <%= goal_form.label :Date, 'Date:' %> 
    <%= goal_form.date_select :Date %> 
    </div> 
    <div> 
    <%= goal_form.label :DueDate, 'DueDate:' %> 
    <%= goal_form.date_select :DueDate %> 
    </div> 

    <!-- Here we call fields_for on the project_form builder instance. 
     The block is called for each member of the tasks collection. --> 
    <% goal_form.fields_for :steps do |step_form| %> 
    <p> 
    <div class="field"> 
     <%= step_form.label :requirement %><br> 
     <%= step_form.text_field :requirement %> 
    </div> 

    <div class="field"> 
     <%= step_form.label :completionTime %><br> 
     <%= step_form.number_field :completionTime %> 
    </div> 

    <% unless step_form.object.new_record? %> 
     <div> 
     <%= step_form.label :_delete, 'Remove:' %> 
     <%= step_form.check_box :_delete %> 
     </div> 
    <% end %> 
    </p> 

    <% end %> 
    <div class="actions"> 
    <%= goal_form.submit %> 
    </div> 
<% end %> 
関連する問題