mercredi 1 mai 2019

After including rails engine layout in application gives routing error?

I am using Rails 5.2.3 and ruby 2.4.0p0

I already have an rails application, now I have created a new Rails engine with some functionality I have included it in the main application as:

In gemfile:

gem 'myengin', path: '/home/vidur/rails_apps/myengin'

For routing:

 mount Myengin::Engine => "/myengin", as: "myengin"   

I want to show the pages in the mounted engine inside the layout of the main application so for doing it I have extended the application controller of the main application in the application controller of the mounted engine as:

module Myengin
   class ApplicationController < ::ApplicationController
    protect_from_forgery with: :exception
  end
end

After doing it it will render the layout of the main application but it will give the routing errors, It will not detect the routing of the main application on these pages and show routing undefined error, But they exists in the routes.rb in the main application. Example:

undefined local variable or method `tukabank_cart_path' for #<#<Class:0x00000004e353b0>:0x00000004e237f0> 

defined in main application routed.rb as:

 resource :tukabank_cart, only: [:show]

similerly for other routes, all the variable defined as _path its gives undefined error But they are defined. why the routing is not getting detected on the of mounted engine pages, is there a way round, or should I keep the layout of the main application free from _path variable of the main application. thanks ain advance

Aucun commentaire:

Enregistrer un commentaire