schneikai
3/22/2014 - 8:24 PM

Use the main apps application layout in a mountable engine. You need to delete "app/views/layouts/katalog/application.html.erb" and change t

Use the main apps application layout in a mountable engine. You need to delete "app/views/layouts/katalog/application.html.erb" and change the following files.

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