Sha256: fef87a9dd88fd6c71663edf5623123c5cbcf1a1a40dde60f5dd978b9dab46774
Contents?: true
Size: 1.19 KB
Versions: 46
Compression:
Stored size: 1.19 KB
Contents
module ActiveAdmin class Resource module Routes # Returns the routes prefix for this config def route_prefix namespace.module_name.try(:underscore) end def route_uncountable? controller.resources_configuration[:self][:route_collection_name] == controller.resources_configuration[:self][:route_instance_name] end # Returns a symbol for the route to use to get to the # collection of this resource 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 private def routes Rails.application.routes.url_helpers end end end end
Version data entries
46 entries across 46 versions & 2 rubygems