Module: Avo::UrlHelpers
- Included in:
- ApplicationController
- Defined in:
- app/helpers/avo/url_helpers.rb
Instance Method Summary collapse
- #edit_resource_path(model:, resource:, **args) ⇒ Object
- #new_resource_path(model:, resource:, **args) ⇒ Object
- #related_resources_path(parent_model, model, keep_query_params: false, **args) ⇒ Object
- #resource_attach_path(resource, model_id, related_name, related_id = nil) ⇒ Object
- #resource_detach_path(model_name, model_id, related_name, related_id = nil) ⇒ Object
- #resource_path(model:, resource:, resource_id: nil, keep_query_params: false, **args) ⇒ Object
- #resources_path(resource:, keep_query_params: false, **args) ⇒ Object
Instance Method Details
#edit_resource_path(model:, resource:, **args) ⇒ Object
39 40 41 |
# File 'app/helpers/avo/url_helpers.rb', line 39 def edit_resource_path(model:, resource:, **args) avo.send :"edit_resources_#{resource.singular_model_key}_path", model, **args end |
#new_resource_path(model:, resource:, **args) ⇒ Object
35 36 37 |
# File 'app/helpers/avo/url_helpers.rb', line 35 def new_resource_path(model:, resource:, **args) avo.send :"new_resources_#{resource.singular_model_key}_path", **args end |
#related_resources_path(parent_model, model, keep_query_params: false, **args) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/avo/url_helpers.rb', line 56 def ( parent_model, model, keep_query_params: false, **args ) return if model.nil? existing_params = {} begin if keep_query_params existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys end rescue end avo.resources_associations_index_path(@parent_resource.model_class.model_name.route_key, @parent_resource.model.id, **existing_params, **args ) end |
#resource_attach_path(resource, model_id, related_name, related_id = nil) ⇒ Object
43 44 45 |
# File 'app/helpers/avo/url_helpers.rb', line 43 def resource_attach_path(resource, model_id, , = nil) helpers.avo.resources_associations_new_path(resource.singular_model_key, model_id, ) end |
#resource_detach_path(model_name, model_id, related_name, related_id = nil) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'app/helpers/avo/url_helpers.rb', line 47 def resource_detach_path( model_name, # teams model_id, # 1 , # admin = nil ) avo.resources_associations_destroy_path(model_name, model_id, , ) end |
#resource_path(model:, resource:, resource_id: nil, keep_query_params: false, **args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/avo/url_helpers.rb', line 19 def resource_path( model:, resource:, resource_id: nil, keep_query_params: false, **args ) if model.respond_to? :id id = model elsif resource_id.present? id = resource_id end avo.send :"resources_#{resource.singular_model_key}_path", id, **args end |
#resources_path(resource:, keep_query_params: false, **args) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/avo/url_helpers.rb', line 3 def resources_path(resource:, keep_query_params: false, **args) return if resource.nil? existing_params = {} begin if keep_query_params existing_params = Addressable::URI.parse(request.fullpath).query_values.symbolize_keys end rescue end # This entry uses `route_key` instead of `model_key` because it's rails that needs `fish_index` to build the correct path avo.send :"resources_#{resource.route_key}_path", **existing_params, **args end |