Ruby on rails 为什么在Rails4中将用户/密码/新建重定向到根目录?
我现在正在Ruby应用程序中使用Desive gem。 似乎密码方法不起作用,因为在某种程度上,Desive controller有点修改。当我键入/users/password/new时,它返回到根目录 我遵循了一个教程,但现在我被困在这个我必须提供给人们的非常重要的方法上 密码\u controller.rb文件位于controllers/users/password\u controller.rb中 代码是Ruby on rails 为什么在Rails4中将用户/密码/新建重定向到根目录?,ruby-on-rails,devise,Ruby On Rails,Devise,我现在正在Ruby应用程序中使用Desive gem。 似乎密码方法不起作用,因为在某种程度上,Desive controller有点修改。当我键入/users/password/new时,它返回到根目录 我遵循了一个教程,但现在我被困在这个我必须提供给人们的非常重要的方法上 密码\u controller.rb文件位于controllers/users/password\u controller.rb中 代码是 class Users::PasswordsController < Dev
class Users::PasswordsController < Devise::PasswordsController
prepend_before_filter :require_no_authentication
# Render the #edit only if coming from a reset password email link
append_before_filter :assert_reset_token_passed, only: :edit
# GET /resource/password/new
def new
self.resource = resource_class.new
end
# POST /resource/password
def create
self.resource = resource_class.send_reset_password_instructions(resource_params)
yield resource if block_given?
if successfully_sent?(resource)
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
else
respond_with(resource)
end
end
我在这个目录中有查看文件
views/users/passwords/create.html.erb, edit.html.erb, new.html.erb
views/users/sessions/new.html.erb
views/users/registrations/edit.html.erb, create.html.erb
路由文件是这样的
devise_for :users, controllers: { passwords: "users/passwords", sessions: "users/sessions", registrations: "users/registrations", omniauth_callbacks: "users/omniauth_callbacks" }
每当我输入时,它都返回到root
这是我的路线文件
new_user_session GET /users/sign_in(.:format) users/sessions#new
user_session POST /users/sign_in(.:format) users/sessions#create
destroy_user_session GET /users/sign_out(.:format) users/sessions#destroy
user_omniauth_authorize GET|POST /users/auth/:provider(.:format) users/omniauth_callbacks#passthru {:provider=>/google_oauth2/}
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) users/omniauth_callbacks#:action
user_password POST /users/password(.:format) users/passwords#create
new_user_password GET /users/password/new(.:format) users/passwords#new
edit_user_password GET /users/password/edit(.:format) users/passwords#edit
PATCH /users/password(.:format) users/passwords#update
PUT /users/password(.:format) users/passwords#update
cancel_user_registration GET /users/cancel(.:format) users/registrations#cancel
user_registration POST /users(.:format) users/registrations#create
new_user_registration GET /users/sign_up(.:format) users/registrations#new
edit_user_registration GET /users/edit(.:format) users/registrations#edit
PATCH /users(.:format) users/registrations#update
PUT /users(.:format) users/registrations#update
DELETE /users(.:format) users/registrations#destroy
POST|GET /:controller(/:action(/:id))(.:format) :controller#:action
root GET / landings#index
当我转到localhost:3000/users/password/new时得到的日志如下所示
开始GET/users/password/new for::1于2015-10-06 04:11:58+0900由用户处理::PasswordsControllernew作为HTML重定向到localhost:3000筛选器链停止作为:is_login呈现或重定向完成302在2ms ActiveRecord中找到:0.0ms这是我在发布地址后立即获得的日志
如果你们有任何提示,请告诉我!!
最好的我通过append/users/password/edit?reset\u password\u token=aaaaaa来修复它
可能是设计错误。您的视图不应该有扩展名“.rb”。根据文件内容,尝试删除或替换为.haml/.erb,并告诉我们您遇到了哪些新问题。在您的描述中,您表示您尝试了users/passwords/new,但链接上显示users/password/new,请确保您没有意外访问密码,您的路由仅为密码单数定义。您可以在转到后发布日志显示的内容吗?当您转到该url时是否已登录?以及-此方法是什么?你登录了吗
new_user_session GET /users/sign_in(.:format) users/sessions#new
user_session POST /users/sign_in(.:format) users/sessions#create
destroy_user_session GET /users/sign_out(.:format) users/sessions#destroy
user_omniauth_authorize GET|POST /users/auth/:provider(.:format) users/omniauth_callbacks#passthru {:provider=>/google_oauth2/}
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) users/omniauth_callbacks#:action
user_password POST /users/password(.:format) users/passwords#create
new_user_password GET /users/password/new(.:format) users/passwords#new
edit_user_password GET /users/password/edit(.:format) users/passwords#edit
PATCH /users/password(.:format) users/passwords#update
PUT /users/password(.:format) users/passwords#update
cancel_user_registration GET /users/cancel(.:format) users/registrations#cancel
user_registration POST /users(.:format) users/registrations#create
new_user_registration GET /users/sign_up(.:format) users/registrations#new
edit_user_registration GET /users/edit(.:format) users/registrations#edit
PATCH /users(.:format) users/registrations#update
PUT /users(.:format) users/registrations#update
DELETE /users(.:format) users/registrations#destroy
POST|GET /:controller(/:action(/:id))(.:format) :controller#:action
root GET / landings#index