1
我將引擎安裝到使用Devise的應用中。而且我將再安裝一個應該使用它的應用程序。所以我決定使用第一臺發動機的設計。當使用安裝引擎的設計時,沒有路由匹配[GET]「/ accounts/sign_in」
config/routes.rb
:
Rails.application.routes.draw do
mount EngineWithDevise::Engine => "/engine_with_devise"
mount MyEngine::Engine => "/my_engine"
end
所有工作正常,但是當我添加以下代碼:
module MyEngine
class ApplicationController < ActionController::Base
before_action :authenticate_account!
end
end
我得到了以下錯誤:
ActionController::RoutingError:
No route matches [GET] "/accounts/sign_in"
所以它重定向到/accounts/sign_in
代替的/devise_with_engine/accounts/sign_in
當我手動訪問它時,登錄成功,然後正常工作。 當我安裝發動機/
它正常工作:
Rails.application.routes.draw do
mount EngineWithDevise::Engine => "/"
mount MyEngine::Engine => "/my_engine"
end
按照manual我增加了路由器名稱:
config.router_name = engine_with_devise
,有沒有全部描述。 但這並沒有幫助。
我使用最後的設計版本
有什麼想法?