Rails 3路由嵌套

时间:2012-10-09 03:21:01

标签: ruby-on-rails-3 routing rails-routing

我的Rails应用程序路由看起来像这样:

match 'Events/New' => 'event#new'
match 'Events/:date' => 'event#show', :date => /[A-Z][a-z]{2}-\d{2}-\d{4}/
match 'Events/:date/Venue' => 'event#venue', :date => /[A-Z][a-z]{2}-\d{2}-\d{4}/
match 'Events/:date/Speakers' => 'event#speakers', :date => /[A-Z][a-z]{2}-\d{2}-\d{4}/

有没有办法筑巢并清理它?我怀疑它正在运行正则表达式:日期多次,而嵌套理论上可以让它运行一次。

1 个答案:

答案 0 :(得分:0)

看看:http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing scope应该可以解决您的问题! 类似的东西:

scope :module => "events" do
  // ...
end