私はアプリケーションをRails 4からRails 5にアップグレードしています。いくつかの私のルートでは未知のリダイレクト301を取得しています。これはどのように見えるかです。Rails 5は望ましくないリダイレクトをアップグレードします
ルート
namespace :api, :path => '/api' do
namespace :v1 do
scope module: 'users' do
post 'users/login', to: 'login#post'
end
end
end
コントローラファイル:私はいくつかのコードを持っていたコントローラ内部
module Api
module V1
class Users::LoginController < ApiController
end
end
end
親コントローラ
module Api
module V1
class ApiController < ActionController::Base
end
end
end
が、私は、私はすべて削除デバッグされたようにコードと問題はまだそこに残っていたので、問題はコントロールのコードにはないと推測しますrs。
テストケース
it "does not authenticate if the Authorization header is not present" do
post '/api/v1/users/login'
expect(json["message"]).to eq("This endpoint requires Authorization in the header")
expect(response.status).to eq 401
end
の代わりにこのようなもの、私は次のエラーを取得します。
Failures:
1) Users API POST /users/login does not authenticate if the Authorization header is not present
Failure/Error: JSON.parse(response.body)
JSON::ParserError:
784: unexpected token at '<html><body>You are being <a href="http://www.example.com/api/v1/users/login.json">redirected</a>.</body></html>'
# /home/vagrant/.rvm/gems/ruby-2.3.3/gems/json-1.8.6/lib/json/common.rb:155:in `parse'
# /home/vagrant/.rvm/gems/ruby-2.3.3/gems/json-1.8.6/lib/json/common.rb:155:in `parse'
# ./spec/support/request_helpers.rb:4:in `json'
# ./spec/requests/api/v1/users/login_spec.rb:12:in `block (3 levels) in <top (required)>'
編集
私は自分のサーバーを起動し、呼び出しを行うための郵便配達を使用する場合、私は、要求がPOST
からGET
に変更されて参照してください。一部のエンドポイントでは、GET
コールが複数回発生します。
Started POST "/api/v1/users/login" for 10.0.2.2 at 2017-11-24 08:49:45 +0000
Started GET "/api/v1/users/login.json" for 10.0.2.2 at 2017-11-24 08:49:46 +0000
編集 私はこれをデバッグについては移動する方法がわからないルート
api_v1_users_login POST /api/v1/users/login(.:format) api/v1/users/login#post
を追加します。何がここで間違っているかもしれないかについてのあらゆるアイデア?
rakeルートの出力を貼り付けます –
すべてのルートを使いますか?そこには多くのものがあります。 – aks
私はログインのルートが必要 –