ruby 在可安装的引擎中使用主应用程序应用程序布局。您需要删除“app / views / layouts / katalog / application.html.erb”并更改t

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 在可安装的引擎中使用主应用程序应用程序布局。您需要删除“app / views / layouts / katalog / application.html.erb”并更改t相关的知识,希望对你有一定的参考价值。

module Katalog
  # It is important that you say <tt>Katalog::ApplicationController</tt> 
  # instead of just <tt>ApplicationController</tt> here.
  class UploadController < Katalog::ApplicationController
    ...
  end
end
# app/helpers/katalog/application_helper.rb
module Katalog
  module ApplicationHelper
    # Added this because Katalog views render in the main apps application layout
    # and we need to make the main apps path helpers available too.
    def method_missing method, *args, &block
      if method.to_s.end_with?('_path') or method.to_s.end_with?('_url')
        if main_app.respond_to?(method)
          main_app.send(method, *args)
        else
          super
        end
      else
        super
      end
    end

    def respond_to?(method)
      if method.to_s.end_with?('_path') or method.to_s.end_with?('_url')
        if main_app.respond_to?(method)
          true
        else
          super
        end
      else
        super
      end
    end
  end
end
# app/controllers/katalog/application_controller.rb
module Katalog
  # Inherit from main apps application controller instead of *ActionController::Base*
  class ApplicationController < ::ApplicationController
  end
end

以上是关于ruby 在可安装的引擎中使用主应用程序应用程序布局。您需要删除“app / views / layouts / katalog / application.html.erb”并更改t的主要内容,如果未能解决你的问题,请参考以下文章