I'm currently using a custom build of a gem that hasn't been updated to work with Rails 5.2 as of now. I've extracted the core files and now I'm faced with an issue where I need to access the routes for the engine internally. All folders for the gem, have the namespace payola - which allows me to access its resources. How can I setup my routes to take into account the namespaced routes for the gem, without including the reference to the engine itself (which is causing duplicates). My routes file is below. When I add the routes to the Rails.application.routes.draw alone, its unable to find the controllers for it.
routes.rb
Rails.application.routes.draw do
get 'mobile_search/index'
mount Payola::Engine => '/payola', as: :payola
mount ActionCable.server => '/cable'
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
mount Resque::Server, :at => "/resque"
mount CountryStateSelect::Rails::Engine, at: "/"
devise_for :admins
devise_for :users, path: '', path_names: {sign_in: 'login', sign_out: 'logout', sign_up: 'signup'}, controllers: {registrations: 'users/registrations'}
devise_scope :user do
put 'user_change_plan', :to => 'users/registrations#user_change_plan'
authenticated do
root to: 'user_dashboard#index', as: 'authenticated_user_root'
end
unauthenticated do
root to: 'home#index', as: 'unauthenticated_user_root'
end
end
devise_scope :admin do
authenticated do
root to: 'admin_dashboard#admin', as: 'authenticated_admin_root'
end
unauthenticated do
root to: 'home#index', as: 'unauthenticated_admin_root'
end
end
resources :after_registration_wizard, only: [:show]
root 'home#index'
end
# Payola
Payola::Engine.routes.draw do
match '/buy/:product_class/:permalink' => 'transactions#create', via: :post, as: :buy
match '/confirm/:guid' => 'transactions#show', via: :get, as: :confirm
match '/status/:guid' => 'transactions#status', via: :get, as: :status
match '/subscribe/:plan_class/:plan_id' => 'subscriptions#create', via: :post, as: :subscribe
match '/confirm_subscription/:guid' => 'subscriptions#show', via: :get, as: :confirm_subscription
match '/subscription_status/:guid' => 'subscriptions#status', via: :get, as: :subscription_status
match '/cancel_subscription/:guid' => 'subscriptions#destroy', via: :delete, as: :cancel_subscription
match '/change_plan/:guid' => 'subscriptions#change_plan', via: :post, as: :change_subscription_plan
match '/change_quantity/:guid' => 'subscriptions#change_quantity', via: :post, as: :change_subscription_quantity
match '/update_card/:guid' => 'subscriptions#update_card', via: :post, as: :update_card
match '/update_customer/:id' => 'customers#update', via: :post, as: :update_customer
match '/create_card/:customer_id' => 'cards#create', via: :post, as: :create_card
match '/destroy_card/:id/:customer_id' => 'cards#destroy', via: :delete, as: :destroy_card
mount StripeEvent::Engine => '/events'
end
I created a scoped module that would render the same results as the engine itself.
routes.rb