Rails class loading skips namespaced class when another class of same name in root namespace is loaded

后端 未结 2 784
长情又很酷
长情又很酷 2021-01-05 06:00

I have two namespaces, each with its own controller and presenter classes: Member::DocumentsController Member::DocumentPresenter Guest::Docum

2条回答
  •  囚心锁ツ
    2021-01-05 06:02

    I think in 3 solutions if you want to mantein the name, one is your second solution.

    1) explicitly require appropriate presenter files in controller files

    2) Execute the full environment class path, like:

    class Guest::DocumentsController < ActionController::Base
        def show
            Guest::DocumentPresenter.new(find_document)
        end
    end
    

    3) Create a file on initialize directory and execute require manually (the worst options :S)

提交回复
热议问题