0
我想猴补丁的路径辅助方法,这样的方法:传球选择散列到
def product_path(product, options={})
url_for(controller: :product, action: :show,
id: product.id, name: product.name.parameterize,
options)
end
我想保留的选项哈希,所以当我引用product_path我能有这样一个方法调用:
product_path(product, anchor: '#product_description')
我上面引用的product_path不起作用,因为我无法将params散列值传递给url_for散列值。最干净的正确方法是什么?
的作品,但我不认为最后一个逗号,其中名称:product.name.parameterize,是必要的 – shicholas