I have an app that will show collections of images according to routes like this:
client '/{{_type}}', controller: 'main', action: 'index'
client '/', {}
The idea is that in MainController#index
I will be able to look at params._type
and do a query like this:
@uploads = store._uploads.where({category: params._type})
I have a nav bar with the links: /
, /spotlight
, /nature
and so on. The first one matches the default route, so the index
action is called. Then clicking on the nav item that links to /spotlight
again calls the index
action (the expected response). But... If I click on the nav item for nature
the index
action is not called, the collection is not refreshed, and I don't the the images that correspond to the category.
I may be taking a "Rails" view of how routing should work because I read this:
The above citation from the Volt docs implies to me that I cannot count on routes to accomplish what I have outlined.
Can anyone clarify what the "correct" way to achieve this goal is?
Adding @ryanstout's answer as it affects this with appropriate code formatting.
client '/{{_type}}', controller: 'main', action: 'index'
# ^^^ Note that the underscore may not be included
# here or you will have an undefined value
def uploads
store._uploads.where({category: params._type})
end
The second part allows for creating a reactive data source whose changes affect the page when the route changes.