简体   繁体   English

Rails路径的路径助手,带有安装引擎的参数

[英]Path helper for rails route, with param that mounts an engine

Hi I have the following route: 嗨,我有以下路线:

mount Spree::Core::Engine, :at => ':city_name/', :as => :spree

that produces urls like /munich/path/in/engine or /new_york/path/in/engine 产生类似/munich/path/in/engine/new_york/path/in/engine网址

How can I use an url helper to produce such an url, that modifies the city and uses an url helper of the engine? 如何使用网址帮助程序生成这样的网址,以修改城市并使用引擎的网址帮助程序? If the engine would provide an url helper for a product (eg product_path(@product) ), is there something like 如果引擎将为产品提供url帮助器(例如product_path(@product) ),是否有类似的内容

spree_path(:city_name => "munich").product_path(@product)

to produce an url like /munich/products/1 ? 产生类似/munich/products/1的网址?

这应该可以使用:

spree.product_path(@product, :city_name => "munich")

正确的方法是使用Engine自己的网址帮助器:

Spree::Core::Engine.routes.url_helpers.product_path

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM