设计edit.html.erb视图时出现语法错误

时间:2018-09-09 21:34:02

标签: ruby-on-rails ruby

基本上,当我登录时,我尝试导航到http://localhost:3000/users/edit 只是检查我是否获得编辑用户信息的表格,但出现此错误:

app/views/devise/registrations/edit.html.erb:16: syntax error, unexpected ':', expecting ')' input_html: { autocomplete: "new-password ^

    <h2>Edit <%= resource_name.to_s.humanize %></h2>

<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <%= f.input :email, required: true, autofocus: true %>

    <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
      <p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
    <% end %>

    <%= f.input :password,
                hint: "leave it blank if you don't want to change it",
                required: false
                input_html: { autocomplete: "new-password" } %>
    <%= f.input :password_confirmation,
                required: false,
                input_html: { autocomplete: "new-password" } %>
    <%= f.input :current_password,
                hint: "we need your current password to confirm your changes",
                required: true,
                input_html: { autocomplete: "current-password" } %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Update" %>
  </div>
<% end %>

<h3>Cancel my account</h3>

<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>

<%= link_to "Back", :back %>

我没有修改任何视图,也没有生成任何用户控制器 我正在使用devise(4.5.0)和Rails 5.2.1和Ruby ruby​​ 2.4.4p296

感谢您的帮助

2 个答案:

答案 0 :(得分:2)

您缺少逗号,请将密码部分更改为下面的密码

<%= f.input :password,
      hint: "leave it blank if you don't want to change it",
      required: false, <= this comma
      input_html: { autocomplete: "new-password" } %>

答案 1 :(得分:1)

您可以关闭它,我发现了错误。在必填项:false行中缺少。 从一开始它就没有用,因为当我生成设计视图时,可能是我的导轨上的一个错误。