Module: ActiveAdmin::Resource::Routes
- Included in:
- Page, ActiveAdmin::Resource
- Defined in:
- lib/active_admin/resource/routes.rb
Instance Method Summary collapse
-
#route_collection_path(params = {}) ⇒ Object
Returns a symbol for the route to use to get to the collection of this resource.
-
#route_prefix ⇒ Object
Returns the routes prefix for this config.
- #route_uncountable? ⇒ Boolean
Instance Method Details
#route_collection_path(params = {}) ⇒ Object
Returns a symbol for the route to use to get to the collection of this resource
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_admin/resource/routes.rb', line 17 def route_collection_path(params = {}) route, required_params = [], [] route << route_prefix if belongs_to? && !belongs_to_config.optional? name = belongs_to_config.target.resource_name.singular route << name required_params << :"#{name}_id" end route << controller.resources_configuration[:self][:route_collection_name] route << (route_uncountable? ? 'index_path' : 'path') route_name = route.compact.join("_").to_sym route_params = params.values_at(*required_params) routes.send(route_name, *route_params) end |
#route_prefix ⇒ Object
Returns the routes prefix for this config
6 7 8 |
# File 'lib/active_admin/resource/routes.rb', line 6 def route_prefix namespace.module_name.try(:underscore) end |
#route_uncountable? ⇒ Boolean
10 11 12 13 |
# File 'lib/active_admin/resource/routes.rb', line 10 def route_uncountable? controller.resources_configuration[:self][:route_collection_name] == controller.resources_configuration[:self][:route_instance_name] end |