ded*_*les 0 ruby ruby-on-rails devise ruby-on-rails-4
我正在使用 Rails 4.2 和设计。每当我尝试使用重置密码页面时,都会出现以下错误:
Nil location provided. Can't build URI. on Password reset
Run Code Online (Sandbox Code Playgroud)
在生产中,它带有 500 内部服务器错误。
带有重置令牌的电子邮件确实会发送。如果用户打开电子邮件中的链接,他们可以返回站点更改密码。尽管如此,单击“重置密码按钮”时总会出现 500 错误。
我以前用过很多次设计,从来没有遇到过这个问题。我怀疑它可能与本教程有关:
并在我的应用程序控制器中显式编写resource_name,resource和devise_mapping方法,但它们并没有干扰任何其他设计路线,即使将它们注释掉,错误仍然存在。
编辑:
我并没有PasswordController坚持使用 Devise 的大多数默认设置。我也没有respond_with在我的应用程序中的任何地方使用。
我的设计模型如下所示:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :confirmable, :lockable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, :omniauth_providers => [:stripe_connect]
validates :username, presence: true
validates :time_zone, presence: true
has_one :teacher, dependent: :destroy
has_many :bookings, foreign_key: :student_id
has_many :reviews, foreign_key: :student_id, dependent: :destroy
has_many :messages, dependent: :destroy
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates_format_of :email, with: VALID_EMAIL_REGEX
end
Run Code Online (Sandbox Code Playgroud)
编辑3:
以下是相关路线:
get 'sessions/create'
devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" }
resources :users, :only =>[:show]
devise_scope :user do
get 'bookings', to: 'bookings#bookings'
end
Run Code Online (Sandbox Code Playgroud)
这是视图:
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, :class => "sky-form" }) do |f| %>
<%= devise_error_messages! %>
<h3 class="text-center"><%= t('.header') %></h3>
<section>
<div class="row">
<label class="label col col-4"><%= t('.email') %></label>
<div class="col col-8">
<label class="input">
<%= f.email_field :email %>
</label>
</div>
</div>
</section>
<footer class="text-right">
<%= f.submit t('.resetpwbtn'), class: "btn btn-theme-bg btn-lg" %>
</footer>
<% end %>
Run Code Online (Sandbox Code Playgroud)
使用新的涡轮增压/热线时,设计可能会发生这种情况。
就我而言,我自定义了要设置的表单 "data-turbo": "false"
像这样:
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { "data-turbo": "false", method: :post }) do |f| %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
999 次 |
| 最近记录: |