我想在我的路线中使用正则表达式。我有一个产品的控制器,但我希望有一个不同的URL结构来访问产品高级路由与Rails3
这些URL应该调用一个动作在我的控制器(Products:show_category(:category)
)
是这样的可能吗?
match "(this|that|andthat)" => "products#show_category", :category => $1
的动作应该是这样的
def show_category
puts params[:category] # <-- "this" if http://host/this/ is called
# ...
end
太棒了,那完美的作品!感谢提示:constraints-Option – Fu86 2010-09-07 06:26:59