我有一个应用程序,它将根据这样的路线显示图像集合:
client '/{{_type}}', controller: 'main', action: 'index'
client '/', {}
这个想法是,MainController#index
我将能够查看params._type
并执行如下查询:
@uploads = store._uploads.where({category: params._type})
我有一个带有链接的导航栏:/
、、/spotlight
等等/nature
。第一个匹配默认路由,因此index
调用该操作。然后单击链接到的导航项/spotlight
再次调用index
操作(预期响应)。但是...如果我单击导航项nature
的index
操作未调用,则集合不会刷新,并且我没有与类别对应的图像。
我可能对路由应该如何工作采取“Rails”视图,因为我读到了这个:
Volt 文档的上述引用对我来说意味着我不能指望路线来完成我所概述的内容。
谁能澄清实现这一目标的“正确”方法是什么?
添加@ryanstout 的答案,因为它会通过适当的代码格式影响这一点。
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
第二部分允许创建响应式数据源,其更改会在路由更改时影响页面。