我的html.erb文件有什么问题?

时间:2016-12-30 15:03:23

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 ruby-on-rails-3.2 erb

从下面的代码中,我收到以下错误:

/home/ubuntu/workspace/portfolio/app/views/projects/_project_form.html.erb:36:语法错误,意外的keyword_ensure,期待输入结束

因为这是一个语法错误,我猜我不需要提供其他细节,但如果你们需要我发帖,请随时提出。

    <%= form_for @project do |f| %>
  <% if @project.errors.any? %>
    <div id="error_explanation">
      <h2>
        <%= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:" %>
      </h2>
      <ul>
        <% @project.errors.full_messages.each do |msg| %>
          <li>
            <%= msg %>
          </li>
        <% end %>
      </ul>
    </div>
  <% end %>
  <div class="field">
    <%= f.label :client %>
      <p>
        <%= @project.client.name %>
      </p>
      <%= f.hidden_field:note_id, value: @project.client.id  %>
    <% end %>
  </div>
  <div class="field">
    <%= f.label :project_description %>
    <%= f.text_area :project_description %>
  </div>
  <div class="field">
    <%= f.label :project_timescale %>
    <%= f.text_field :project_timescale %>
  </div>
  <div class="actions">
    <%= f.submit 'Save' %>
  </div>
  <% end %>

1 个答案:

答案 0 :(得分:0)

编辑表格: -

<%= form_for @project do |f| %>
  <% if @project.errors.any? %>
    <div id="error_explanation">
      <h2>
        <%= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:" %>
      </h2>
      <ul>
        <% @project.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <%= f.hidden_field :note_id, value: @project.client.id  %>
  <div class="field">
    <%= f.label :client %>
      <p>
        <%= @project.client.name %>
      </p>
  </div>
  <div class="field">
    <%= f.label :project_description %>
    <%= f.text_area :project_description %>
  </div>
  <div class="field">
    <%= f.label :project_timescale %>
    <%= f.text_field :project_timescale %>
  </div>
  <div class="actions">
    <%= f.submit 'Save' %>
  </div>
<% end %>

由于<% end %>

以下额外hidden field,错误即将发生