我现在在一个Ruby应用程序中使用了设计gem。密码方法似乎不起作用,因为不知何故,控制器被修改了一点。当我输入/users/password/new时,它返回到根目录。
我遵循了一个教程,但现在我被这个非常重要的方法困住了,我必须提供给人们。
passwords_controller。Rb文件位于controllers/users/password_controller.rb.
代码是
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
(这是一个典型的设计控制器内容)
我的用户。Rb模型如下:
...
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable, :omniauth_providers => [:google_oauth2] #, :confirmable
...
我在这个目录下有视图文件。
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" }
当我输入"http://localhost:3000/users/password/new"时,它返回到根目录
这是我的路由文件。
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时,我得到的日志是这样的。
Started GET "/users/password/new" for::1 at 2015-10-06 04:11:58 +0900由用户处理::passwordcontroller #new as HTML重定向到localhost:3000过滤器链停止为:is_login呈现或重定向完成302在2ms中找到(ActiveRecord: 0.0ms)这是我在发布地址后得到的日志
如果你们有任何提示,请让我知道!!最好的我通过append/users/password/edit?reset_password_token = aaaaaa可能是设计错误