Module: SimpleDrilldown::Routing

Defined in:
lib/simple_drilldown/routing.rb

Overview

Routing helper methods

Instance Method Summary collapse

Instance Method Details

#draw_drilldown(path, controller = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/simple_drilldown/routing.rb', line 6

def draw_drilldown(path, controller = nil)
  path = "#{path}_drilldown" unless /_drilldown$/.match?(path)
  controller ||= path
  get "#{path}(.:format)" => "#{controller}#index", as: path
  scope path, controller: controller, as: path do
    { excel_export: :xlsx, excel_export_records: :xlsx, html_export: :html }.each do |action, format|
      get action, defaults: { format: format }
    end
    get 'choices/:dimension_name', action: :choices, as: :choices
    yield if block_given?
  end
end