0

I have a rails engine that has routes, views, models and controllers plugged into the host application.

I mount the engine in host routes like so:

mount HelpCenter::Engine, at: "/help_center"

When I go to a view provided by the engine (it is using a layout from the host), it is getting errors when it tries to resolve routes from the navigation bar (host routes).

How do I provide routes from the host into the engine?

Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
Rich
  • 5,603
  • 9
  • 39
  • 61

2 Answers2

2

You need to use

main_app.route_from_my_host_application

This way engine will find for the path in your host routes

Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
0

Take a look at the answer in How can I make routes from a Rails 3 engine available to the host application?

Change config.routes in your engine to:

Rails.application.routes.draw do  # NOT MyEngineName::Engine.routes.draw
  resources :classrooms
end
Community
  • 1
  • 1
kcdragon
  • 1,724
  • 1
  • 14
  • 23
  • Thanks for the link, however this solution is not going to scale across multiple apps. – Rich Aug 18 '16 at 23:02
  • 2
    How do I use the url helpers from the rails engine? where do I define what the host is so I don't get this error: `Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true` – Jwan622 Nov 30 '16 at 17:31