如何在URL中获取日期

时间:2015-11-07 22:45:03

标签: ruby-on-rails

我的router.rb

resources :post_categories, :path => '', :only => [:show] do
    resources :posts, :path => '', :only => [:show]
end

我得到了你需要的东西

/category/id
/category

如何获取此网址?

/category/2015/11/08/id

我想做这样的事情

  resources :post_categories, path: '', only: :show do
    resources :posts, path: '/:year/:month/:day', only: :show, constraints: { year: /\d{4}/, month: /\d{2}/, day: /\d{2}/ }
  end

但我不明白如何让工人

0 个答案:

没有答案