Module: RubyUIAdmin::Views::PathHelpers
- Included in:
- ActionForm, ActionTrigger, Base, FieldValue, ShowTab
- Defined in:
- app/components/ruby_ui_admin/views/path_helpers.rb
Overview
Resolves the dynamic per-resource engine routes from inside Phlex views.
rc is a resource class. Engine routes are reached through the mounted
ruby_ui_admin proxy (provided by RailsHelpers / Routes).
Instance Method Summary collapse
-
#attachment_url(blob, disposition: nil) ⇒ Object
Path to an ActiveStorage blob.
- #resource_edit_path(rc, record) ⇒ Object
- #resource_index_path(rc) ⇒ Object
- #resource_new_path(rc) ⇒ Object
- #resource_show_path(rc, record) ⇒ Object
Instance Method Details
#attachment_url(blob, disposition: nil) ⇒ Object
Path to an ActiveStorage blob. Generated via the application's url helpers (NOT the
request-bound main_app proxy): ActiveStorage's blob route is a direct route, and inside
a mounted engine the proxy prepends the engine's SCRIPT_NAME (e.g. /admin/rails/...),
which 404s — AS lives at the host root. disposition: "attachment" forces a download.
29 30 31 32 33 |
# File 'app/components/ruby_ui_admin/views/path_helpers.rb', line 29 def (blob, disposition: nil) opts = {only_path: true} opts[:disposition] = disposition if disposition Rails.application.routes.url_helpers.rails_blob_path(blob, **opts) end |
#resource_edit_path(rc, record) ⇒ Object
21 22 23 |
# File 'app/components/ruby_ui_admin/views/path_helpers.rb', line 21 def resource_edit_path(rc, record) ruby_ui_admin.public_send("edit_resources_#{rc.singular_route_key}_path", record) end |
#resource_index_path(rc) ⇒ Object
9 10 11 |
# File 'app/components/ruby_ui_admin/views/path_helpers.rb', line 9 def resource_index_path(rc) ruby_ui_admin.public_send("resources_#{rc.route_key}_path") end |
#resource_new_path(rc) ⇒ Object
13 14 15 |
# File 'app/components/ruby_ui_admin/views/path_helpers.rb', line 13 def resource_new_path(rc) ruby_ui_admin.public_send("new_resources_#{rc.singular_route_key}_path") end |
#resource_show_path(rc, record) ⇒ Object
17 18 19 |
# File 'app/components/ruby_ui_admin/views/path_helpers.rb', line 17 def resource_show_path(rc, record) ruby_ui_admin.public_send("resources_#{rc.singular_route_key}_path", record) end |