ruby-on-rails - 设计 edit.html.erb View 中的语法错误

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

我没有修改任何 View ,也没有生成任何用户 Controller 我正在使用 devise (4.5.0) 和 Rails 5.2.1 以及 Ruby ruby​​ 2.4.4p296

感谢帮助

最佳答案

您缺少一个逗号,请将密码部分更改为我下面的内容

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

关于ruby-on-rails - 设计 edit.html.erb View 中的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52248822/

相关文章:

ruby-on-rails - 将 searchkick 与 elasticsearch 插件一起使用

ruby-on-rails - 如何测试自定义 uploader 是否有效?

ruby - 在 Manjaro Deepin 中安装 Vagrant 插件时出错

ruby-on-rails - 我在使用 Rails 4.1 路由时遇到问题

java - Java .NET与PHP Rails

ruby-on-rails - 是否有 Rails 控制台命令(Rails 3+)来重新加载更改后的代码?

javascript - 使用 Javascript 上传到 Rails Active Storage

ruby-on-rails - 如何在 rspec 测试中创建临时表

ruby-on-rails - Rails - 如何对每个方法执行一个方法调用,就像 Controller 对 `render` 所做的那样

ruby-on-rails - 如何使所有查询模型继承一个计算的sql列?