die folgende Reglerstruktur Gegeben:Rails Modul Anwendungsbereich
# application_controller.rb
class ApplicationController < ActiveController::Base; end
# pages_controller.rb
class PagesController < ApplicationController; end
# admin/application_controller.rb
module Admin
class ApplicationController < ::ApplicationController; end
end
# admin/pages_controller.rb
module Admin
class PagesController < ApplicationController; end
end
Man würde erwarten, Admin::PagesController
von Admin::ApplicationController
zu erben und es tut. Aber ich habe bemerkt, dass es manchmal von ::ApplicationController
erbt.
So entschied ich es nicht zu riskieren, zu und verändern Erklärung aller Regler in /admin
speziell Admin::ApplicationController
# admin/pages_controller.rb
module Admin
class PagesController < Admin::ApplicationController; end
end
Okay, das funktioniert, zielen, sondern von dem, was ich weiß, dass es richtig war in erster Linie. Warum erbt Rails manchmal einen falschen Controller?
Admin::PagesController
manchmal erbt von ApplicationController
statt Admin::ApplicationController
trotz beide module Admin
ich ähnliches Problem erlebt hatte !!! – Hardik