Class: ActiveAdmin::Resource::Routes::RouteBuilder
- Inherits:
-
Object
- Object
- ActiveAdmin::Resource::Routes::RouteBuilder
- Defined in:
- lib/active_admin/resource/routes.rb
Instance Method Summary collapse
- #batch_action_path(params, additional_params = {}) ⇒ Object
- #collection_path(params, additional_params = {}) ⇒ Object
-
#initialize(resource) ⇒ RouteBuilder
constructor
A new instance of RouteBuilder.
-
#instance_path(instance, additional_params = {}) ⇒ String
The path to this resource collection page.
-
#member_action_path(action, instance, additional_params = {}) ⇒ String
The path to the member action of this resource.
Constructor Details
#initialize(resource) ⇒ RouteBuilder
Returns a new instance of RouteBuilder.
47 48 49 |
# File 'lib/active_admin/resource/routes.rb', line 47 def initialize(resource) @resource = resource end |
Instance Method Details
#batch_action_path(params, additional_params = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/active_admin/resource/routes.rb', line 60 def batch_action_path(params, additional_params = {}) route_name = route_name( resource.resources_configuration[:self][:route_collection_name], action: :batch_action, suffix: (resource.route_uncountable? ? "index_path" : "path") ) query = params.slice(:q, :scope) query = query.permit!.to_h routes.public_send route_name, *route_collection_params(params), additional_params.merge(query) end |
#collection_path(params, additional_params = {}) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/active_admin/resource/routes.rb', line 51 def collection_path(params, additional_params = {}) route_name = route_name( resource.resources_configuration[:self][:route_collection_name], suffix: (resource.route_uncountable? ? "index_path" : "path") ) routes.public_send route_name, *route_collection_params(params), additional_params end |
#instance_path(instance, additional_params = {}) ⇒ String
Returns the path to this resource collection page.
75 76 77 78 79 |
# File 'lib/active_admin/resource/routes.rb', line 75 def instance_path(instance, additional_params = {}) route_name = route_name(resource.resources_configuration[:self][:route_instance_name]) routes.public_send route_name, *route_instance_params(instance), additional_params end |
#member_action_path(action, instance, additional_params = {}) ⇒ String
Returns the path to the member action of this resource.
85 86 87 88 89 90 |
# File 'lib/active_admin/resource/routes.rb', line 85 def member_action_path(action, instance, additional_params = {}) path = resource.resources_configuration[:self][:route_instance_name] route_name = route_name(path, action: action) routes.public_send route_name, *route_instance_params(instance), additional_params end |