我的应用程序中有一些标准的嵌套路由,我想使用subdomain-fu实现子域。所以我现在正在做这件事:
example.com/stores/name_of_store/products/name_of_product我想这样做:
name_of_store.example.com/products/name_of_product似乎有一些关于子域-fu在子域-fu灯塔票中嵌套路由的失败的讨论,但那个灯塔项目不再是公开的,所以我不能审查他们得出的任何结论。
如果能听到人们关于你如何使用subdomain-fu实现嵌套路由的消息,那就太好了。
谢谢!
发布于 2010-03-16 23:27:51
您根本不应该需要嵌套的路由来实现这一点。您可以只使用subdomain_fu (或手动)查找current_store,然后使用一个基本的ProductsController将查找范围限定为商店中的产品:
# ApplicationController
def current_store
@current_store ||= Store.find_by_subdomain(request.host)
end
helper_method :current_store
# ProductsController
def index
@products = current_store.products.all
endhttps://stackoverflow.com/questions/2454520
复制相似问题