Skip to content

Instantly share code, notes, and snippets.

@ukstv
Created September 24, 2013 11:29
Show Gist options
  • Save ukstv/6683443 to your computer and use it in GitHub Desktop.
Save ukstv/6683443 to your computer and use it in GitHub Desktop.
dras_client_path
module ActiveAdmin
class Resource
module Controllers
# Returns a properly formatted controller name for this
# config within its namespace
def controller_name
[namespace.module_name, resource_name.plural.camelize + "Controller"].compact.join('::')
end
# Returns the controller for this config
def controller
@controller ||= controller_name.constantize
end
# Returns the routes prefix for this config
def route_prefix
namespace.module_name.try(:underscore)
end
# Returns a symbol for the route to use to get to the
# collection of this resource
def route_collection_path
route = [
route_prefix,
controller.resources_configuration[:self][:route_collection_name],
'path'
]
route.compact.join('_').to_sym
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment