Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/admin_space/route.rb

Instance Method Summary collapse

Instance Method Details

#admin_space(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/admin_space/route.rb', line 3

def admin_space *args
  namespace :admin, module: :admin_space do
    with_options controller: :base do |admin|
      yield admin
    end

    # List all model and build routes
    models = []
    Dir.glob( 'app/models/*' ).each do |f|
      models << File.basename( f ).gsub( /^(.+).rb/, '\1')
    end

    models.each do |model|
      eval("resources :#{model.pluralize}, controller: :base")
    end
  end
end