Sha256: 1a3250f4c72b576fede4463fc24d0f359ed5ce857489174f40a55511a7fff873

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 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: "#{model.name.underscore}_import_form")
        send(:post, 'import', to: "#{model.name.underscore}#import", as: "#{model.name.underscore}_import")
      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: "#{model.name.underscore}_reset_sort_columns")
      end
    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: "#{model.name.underscore}_history")
        else
          send(act.verb, act.path.present? ? act.path : act.name, to: "#{model.name.underscore}##{act.name}", as: "#{model.name.underscore}_#{act.name}")
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cm-admin-2.3.4 config/routes.rb
cm-admin-2.3.3 config/routes.rb
cm-admin-2.3.2 config/routes.rb
cm-admin-2.3.1 config/routes.rb
cm-admin-2.3.0 config/routes.rb
cm-admin-2.2.1 config/routes.rb
cm-admin-2.2.0 config/routes.rb