我目前正在使用此鏈接的Rails API的JWT身份驗證: https://github.com/nsarno/knock 我仔細地遵循了她的指示。但是,我仍然無法使用剛纔註冊的用戶名和密碼登錄。我可以沒有錯誤登記,並告訴我這個消息:沒有路由匹配[POST]「/ knock/user_token」
Started POST "/users" for ::1 at 2016-12-20 22:28:32 -0500
Processing by UsersController#create as HTML
Parameters: {"user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}}
(0.4ms) BEGIN
SQL (0.8ms) INSERT INTO "users" ("email", "password_digest", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [["email", "[email protected]"], ["password_digest", "$2a$10$1UAPAV92l.pHhbT.L3BvfOP7ieuy9yU2cdWdwy9VsVnTHjaRECB0W"], ["created_at", 2016-12-21 03:28:32 UTC], ["updated_at", 2016-12-21 03:28:32 UTC]]
(28.7ms) COMMIT
[active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (1.42ms)
Completed 200 OK in 162ms (Views: 21.2ms | ActiveRecord: 34.3ms)
不過,我得到這個錯誤,如果我只用用戶名登錄名和密碼我註冊:
Started POST "/knock/user_token" for ::1 at 2016-12-20 22:29:02 -0500
ActionController::RoutingError (No route matches [POST] "/knock/user_token"):
這裏是路線.rb
Rails.application.routes.draw do
resources :cars
get '/users/current-user', to: "current_user#show"
resources :users
mount Knock::Engine => "/knock"
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
這裏是耙路的輸出| grep的敲
knock /knock Knock::Engine
auth_token POST /auth_token(.:format) knock/auth_token#create
這裏是routers.rb
Rails.application.routes.draw do
post 'user_token' => 'user_token#create'
resources :cars
get '/users/current-user', to: "current_user#show"
resources :users
mount Knock::Engine => "/knock"
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
我該如何解決這個問題的配置?
請發佈'routes.rb'。 – 31piy
@ 31piy已發佈。我只是按照她的指示 –
請寄出'rake routes | grep knock' – unkmas