Created
September 24, 2013 11:29
-
-
Save ukstv/6683443 to your computer and use it in GitHub Desktop.
dras_client_path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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