Ruby on rails Rails设计了呼叫柱而不是设置重置密码
我正在使用Desive进行身份验证,我在恢复密码表单中遇到问题,该表单的链接是通过电子邮件发送的。当我定义新密码时,表单发送的是POST请求,而不是PUT。它正在重定向到用户/密码,并带有“电子邮件不能为空”通知 因此,edit.html.erb有method::put,但它不起作用。Ruby on rails Rails设计了呼叫柱而不是设置重置密码,ruby-on-rails,rest,devise,erb,devise-recoverable,Ruby On Rails,Rest,Devise,Erb,Devise Recoverable,我正在使用Desive进行身份验证,我在恢复密码表单中遇到问题,该表单的链接是通过电子邮件发送的。当我定义新密码时,表单发送的是POST请求,而不是PUT。它正在重定向到用户/密码,并带有“电子邮件不能为空”通知 因此,edit.html.erb有method::put,但它不起作用。 我整天都被困在这里面,还没找到出路 这是完整的edit.html.erb <h2>Change your password</h2> <%= form_for(resource,
我整天都被困在这里面,还没找到出路
这是完整的edit.html.erb
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: user_password_path(resource_name), method: :PUT) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
服务器日志
提前感谢我使用设计密码重置功能遇到了同样的问题。我正在向API Rails应用程序(
config.API_only=true
)添加designe,显然,负责识别隐藏方法属性并将请求更改为PUT/PATCH请求的Rack::MethodOverride
中间件不包括在仅API的中间件堆栈中。因此,请求将其作为POST请求发送到主应用程序
我在config/application.rb
中添加了以下行,解决了这个问题:
config.middleware.insert_after Rack::Runtime, Rack::MethodOverride
我在使用Desive密码重置功能时遇到了同样的问题。我正在向API Rails应用程序(
config.API_only=true
)添加designe,显然,负责识别隐藏方法属性并将请求更改为PUT/PATCH请求的Rack::MethodOverride
中间件不包括在仅API的中间件堆栈中。因此,请求将其作为POST请求发送到主应用程序
我在config/application.rb
中添加了以下行,解决了这个问题:
config.middleware.insert_after Rack::Runtime, Rack::MethodOverride
如果您检查表单元素,它是否显示method=“put”?
是这样的。您使用的是哪个版本的Rails?您是否正确设置了rails ujs
?正是这个库使得对HTML表单的PUT请求成为可能。如果您检查表单元素,它是否显示method=“put”?
是这样的。您使用的是哪个版本的Rails?您是否正确设置了rails ujs
?正是这个库使得对HTML表单的PUT请求成为可能。
constraints subdomain: 'api' do
scope module: 'user' do
devise_for :users,
path: '/user',
path_names: {
registration: 'signup',
sign_in: 'login',
sign_out: 'logout'
},
controllers: {
sessions: 'user/sessions',
registrations: 'user/registrations',
passwords: 'user/passwords'
}
config.middleware.insert_after Rack::Runtime, Rack::MethodOverride