Sha256: 4b1c973aa877c2a8972abf34e0a4f1f709dcad2ace5009f0de677b711a4fea7c

Contents?: true

Size: 1.52 KB

Versions: 16

Compression:

Stored size: 1.52 KB

Contents

CmAdmin::Engine.routes.draw do
  controller 'static' do
    get '/', action: 'dashboard'
    get '/access-denied', action: 'error_403'
  end

  controller 'exports' do
    post '/export_to_file', action: 'export'
  end

  # Defining action routes for each model
  CmAdmin.config.cm_admin_models.each do |model|
    if model.importer
      scope model.name.tableize do
        send(:get, 'import', to: "#{model.name.underscore}#import_form", as: "cm_import_form_#{model.name.underscore}")
        send(:post, 'import', to: "#{model.name.underscore}#import", as: "cm_import_#{model.name.underscore}")
      end
    end

    if model.sort_columns.present?
      scope model.name.tableize do
        send(:post, 'reset_sort_columns', to: "#{model.name.underscore}#reset_sort_columns", as: "cm_reset_sort_columns_#{model.name.underscore}")
      end
    end

    scope model.name.tableize do
      send(:get, 'fetch_drawer', to: "#{model.name.underscore}#fetch_drawer", as: "cm_fetch_drawer_#{model.name.underscore}")
    end

    model.available_actions.sort_by { |act| act.name }.each do |act|
      scope model.name.tableize do
        # Define route only when action trail related field is present
        if act.name == 'history'
          send(:get, ':id/history', to: "#{model.name.underscore}#history", as: "cm_history_#{model.name.underscore}")
        else
          send(act.verb, act.path.present? ? act.path : act.name, to: "#{model.name.underscore}##{act.name}", as: "cm_#{act.name}_#{model.name.underscore}")
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cm-admin-3.0.15 config/routes.rb
cm-admin-3.0.14 config/routes.rb
cm-admin-3.0.13 config/routes.rb
cm-admin-3.0.12 config/routes.rb
cm-admin-3.0.11 config/routes.rb
cm-admin-3.0.10 config/routes.rb
cm-admin-3.0.9 config/routes.rb
cm-admin-3.0.8 config/routes.rb
cm-admin-3.0.7 config/routes.rb
cm-admin-3.0.6 config/routes.rb
cm-admin-3.0.5 config/routes.rb
cm-admin-3.0.4 config/routes.rb
cm-admin-3.0.3 config/routes.rb
cm-admin-3.0.2 config/routes.rb
cm-admin-3.0.1 config/routes.rb
cm-admin-3.0.0 config/routes.rb