Answer the question
In order to leave comments, you need to log in
Date in url how to implement?
Hello.
There is a routing of this format
resources :post_categories, :path => '', :only => [:show] do
resources :posts, :path => '', :only => [:show]
end
/category/id
/category
/category/2015/11/08/id
Answer the question
In order to leave comments, you need to log in
As I wrote, you should learn the basics.
In this case it is
For example:
Params[:year], params[: month], params[: day], params[: id] will be available in the controller
Again, study the rails guide)
Your comment will probably be like this:
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question