Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/accountability/cartographer.rb

Instance Method Summary collapse

Instance Method Details

#accountability_views_for(*tenants) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/accountability/cartographer.rb', line 5

def accountability_views_for(*tenants)
  options = tenants.extract_options!

  options[:path_prefix] ||= options[:path] if options[:path_prefix].nil?

  cartographer = proc do
    namespace :accountability, path: options[:path_prefix], as: :accountability do
      resources :accounts, only: i[index show]
      resources :products
      resources :order_groups, path: 'orders' do
        member do
          post :add_item
        end
      end
      root to: 'products#index'
    end
  end

  cartographer.call

  Accountability::Engine.routes.draw(&cartographer)
end