lib/active_admin/router.rb in activeadmin-0.6.6 vs lib/active_admin/router.rb in activeadmin-1.0.0.pre1
- old
+ new
@@ -16,27 +16,27 @@
define_root_routes router
define_resource_routes router
end
def define_root_routes(router)
- router.instance_exec @application.namespaces.values do |namespaces|
+ router.instance_exec @application.namespaces do |namespaces|
namespaces.each do |namespace|
if namespace.root?
- root :to => namespace.root_to
+ root namespace.root_to_options.merge(to: namespace.root_to)
else
namespace namespace.name do
- root :to => namespace.root_to
+ root namespace.root_to_options.merge(to: namespace.root_to)
end
end
end
end
end
# Defines the routes for each resource
def define_resource_routes(router)
router.instance_exec @application.namespaces, self do |namespaces, aa_router|
- resources = namespaces.values.map{ |n| n.resources.values }.flatten
+ resources = namespaces.flat_map{ |n| n.resources.values }
resources.each do |config|
routes = aa_router.resource_routes(config)
# Add in the parent if it exists
if config.belongs_to?
@@ -45,11 +45,11 @@
# If it's optional, make the normal resource routes
instance_exec &belongs_to if config.belongs_to_config.optional?
# Make the nested belongs_to routes
# :only is set to nothing so that we don't clobber any existing routes on the resource
- resources config.belongs_to_config.target.resource_name.plural, :only => [] do
+ resources config.belongs_to_config.target.resource_name.plural, only: [] do
instance_exec &belongs_to
end
end
end
@@ -78,17 +78,17 @@
build_action = proc{ |action|
build_route.call(action.http_verb, action.name)
}
case config
when ::ActiveAdmin::Resource
- resources config.resource_name.route_key, :only => config.defined_actions do
+ resources config.resource_name.route_key, only: config.defined_actions do
member do
config.member_actions.each &build_action
end
collection do
config.collection_actions.each &build_action
- post :batch_action
+ post :batch_action if config.batch_actions_enabled?
end
end
when ::ActiveAdmin::Page
page = config.underscored_resource_name
get "/#{page}" => "#{page}#index"