我尝试更新用户信息,但每当我输入当前密码并点击更新时,我收到此消息Current password can't be blank
。
通过添加<nav>
栏,我对设计编辑表单做了一些更新,但我不认为这是问题所在。我没有对默认设备控制器进行任何更改。
这是我的编辑表格:
<% if vendor_signed_in? %>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to "Discount Now", edit_vendor_registration_path, class: "navbar-brand", id: "logo" %>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li> <%= link_to "Home", edit_vendor_registration_path %> </li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Signed in as <%= current_vendor.name %></li>
<li><%= link_to "log out", destroy_vendor_session_path,:method => :delete, id: "nav-login-button", type: "button", class: "btn btn-primary navbar-btn"%></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<body>
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :address %><br />
<%= f.text_field :address, autofocus: true %>
</div>
<div class="field">
<%= f.label :discount_information %><br />
<%= f.text_area :discount_info, autofocus: true %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>
</body>
<%else %>
<% link_to "sign up", new_vendor_session_path%>
<% end %>
答案 0 :(得分:1)
我认为不允许使用current_password参数,请检查您的控制台日志。它将显示未经许可的参数。 尝试通过设计注册控制器或在 configure_permitted_parameters 方法中的应用程序控制器中允许它。希望它能奏效。