Ruby on rails 在忘记密码时设计路由错误
当我点击Ruby on rails 在忘记密码时设计路由错误,ruby-on-rails,ruby-on-rails-3,devise,Ruby On Rails,Ruby On Rails 3,Devise,当我点击 这需要我去 由于路由错误 ActionController::RoutingError in Devise/passwords#new Showing app/views/devise/passwords/new.html.erb where line #3 raised: No route matches {:controller=>"users", :action=>"password", :id=>:user} 编辑: new.html.erb此行出现错
这需要我去
由于路由错误
ActionController::RoutingError in Devise/passwords#new
Showing app/views/devise/passwords/new.html.erb where line #3 raised:
No route matches {:controller=>"users", :action=>"password", :id=>:user}
编辑:
new.html.erb此行出现错误
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
resource\u name,:url=>password\u path(resource\u name),:html=>{:method=>:post})do | f |%>
密码\u controller.rb
class Devise::PasswordsController < ApplicationController
#prepend_before_filter :require_no_authentication
include Devise::Controllers::InternalHelpers
access_control do
allow all
end
# GET /resource/password/new
def new
build_resource({})
render_with_scope :new
end
# POST /resource/password
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
if successful_and_sane?(resource)
set_flash_message(:notice, :send_instructions) if is_navigational_format?
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
else
respond_with_navigational(resource){ render_with_scope :new }
end
end
# GET /resource/password/edit?reset_password_token=abcdef
def edit
self.resource = resource_class.new
resource.reset_password_token = params[:reset_password_token]
render_with_scope :edit
end
# PUT /resource/password
def update
self.resource = resource_class.reset_password_by_token(params[resource_name])
if resource.errors.empty?
set_flash_message(:notice, :updated) if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => redirect_location(resource_name, resource)
else
respond_with_navigational(resource){ render_with_scope :edit }
end
end
protected
# The path used after sending reset password instructions
def after_sending_reset_password_instructions_path_for(resource_name)
new_session_path(resource_name)
end
end
类设计::密码控制器在发送\u重置\u密码\u指令\u路径\u(资源\u名称))
其他的
用导航(资源){render_with_scope:new}响应_
结束
结束
#获取/资源/密码/编辑?重置密码\u令牌=abcdef
定义编辑
self.resource=resource\u class.new
resource.reset\u password\u token=参数[:reset\u password\u token]
使用\u范围渲染\u:编辑
结束
#输入/资源/密码
def更新
self.resource=resource\u class.通过\u令牌重置\u密码(参数[resource\u name])
如果resource.errors.empty?
如果是导航格式,则设置闪光消息(:注意,:更新)?
登录(资源名称、资源)
使用资源响应\u,:location=>重定向\u位置(资源\u名称,资源)
其他的
用导航(资源){render_with_scope:edit}响应_
结束
结束
受保护的
#发送重置密码指令后使用的路径
发送后定义重置密码指令路径(资源名称)
新建会话路径(资源名称)
结束
结束
我认为您在routes.rb中缺少这一行
devise_for :users
如果这对您没有帮助,我建议您遵循以下两条铁路路线:
您将在那里找到所有必要的信息。我遇到了类似的问题。我的用户模型中缺少
可恢复的模型:
class User
devise :database_authenticatable,
:registerable,
:validatable,
:recoverable
end
感谢您的响应,但仍然给出了相同的路由错误。没有路由匹配{:controller=>“users”,:action=>“password”,:id=>:user}您确定资源名称不是nil吗?你能告诉我app/views/designe/passwords/new.html.erb的错误行以及负责呈现此视图的控制器操作吗?更改并添加了视图和控制器你的路由中是否有“designe_:users”,rb?
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update