Skip to content

Better support for shallow routes #203

@brendon

Description

@brendon

This is just a quick ping to test your appetite for modifications to decent_exposure so that it more smoothly supports shallow routes in Rails.

I've been working around it for many years now with more convoluted exposures but it could be something that the gem supports natively. I'm not sure if you're still using the gem in your own work day to day and if you've come across this yourself?

Primary considerations for shallow routes:

  • The model hierarchy is built backward from the deepest findable resource rather than finding the shallowest and using this to scope the finding of deeper resources.
  • Shallow routes sometimes depend on the parent route (for new, create and index). The best way to detect this is via the presence of the parent_id param. The id param will only ever be present for the child resource.

That's all I can think of off the top of my head, but I just wanted to raise it again in case you're more open to it these days :D

This is an example of my more convoluted exposures:

  expose :form, id: :form_id, build: -> { element.form }
  expose :elements, from: :form
  expose :element, id: :id, model: 'Forms::Element', scope: -> (model) { params[:id] ? model : elements },
    build_params: -> { element_params }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions