在我的Rails 4項目中,我有一個引擎Blorgh,我根據Rails Guides 製作然後我將它安裝到我的應用程序中。一切都很好,沒有問題。當我在安裝的引擎中使用聲明性授權時出現重定向錯誤
我目前的應用程序使用declarative_authorization。它在我的應用程序內工作正常。 當我在引擎控制器中使用filter_resource_access
時,出現重定向錯誤。
登錄權限後否認:
: Redirected to http://0.0.0.0:3000/blog/
: Filter chain halted as :filter_access_filter rendered or redirected
: Completed 302 Found in 3ms (ActiveRecord: 0.3ms)
謝謝你們。
有些代碼: 引擎application_controller.rb
module Blorgh
class ApplicationController < ActionController::ApplicationController
end
end
引擎posts_controller.rb
module Blorgh
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
filter_resource_access
...
引擎的routes.rb
Blorgh::Engine.routes.draw do
resources :posts do
resources :comments
end
root to: "posts#index"
end
應用的routes.rb
mount Blorgh::Engine, at: "/blog"
除了引擎中的filter_resource_access,一切都是非凡的。 current_user.inspect引擎控制器返回正確的輸出,這意味着我可以通過引擎訪問應用程序中的方法。只需要找出當filter_resource_access返回權限被拒絕時如何將用戶重定向到應用程序主目錄。
如果您需要更多代碼,請讓我知道。
再次感謝。
你可能想要發佈一些實際的代碼。從你所說的話很難猜出發生了什麼 – Nikolay