【发布时间】:2010-09-06 16:05:52
【问题描述】:
我想在我的路由中使用正则表达式。我有一个 Products 控制器,但我想要一个不同的 URL 结构来访问产品
这些 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
【问题讨论】:
标签: ruby-on-rails regex routing