認証が失敗した場合、私はroot_pathにリダイレクトしようとしています。 現在、HTTP Basicを使用してページの本文を変更しています。アクセスが拒否されました。ここでRails authenticate_or_request_with_http_basic response
は私のコントローラです:
class ProjectsController < ApplicationController
before_filter :http_basic_auth, only: [:show]
def http_basic_auth
if (authenticate_or_request_with_http_basic do |user, password| password == @project.passcode && user == @project.passcode end if @project.private?)
true
else
response.headers["Location"] = url_for(root_path)
end
end
end
は以下を調査したが、私はまだそれが権利を取得することはできませんよ。
Rails: What is the location option for in the render method
をredirect_to root_path'? – Aleksey
私は試しましたが、うまく動作しませんでした – Asan
それは確かに動作します。 'redirect_to'でない状態で何かが間違っているかもしれません – Aleksey