A
A
alexnotonfire2015-01-03 23:31:03
Ruby on Rails
alexnotonfire, 2015-01-03 23:31:03

How to make URL with date separated by slashes?

I'm using the Friendly_id gem in a Rails 4 application to make URLs friendlier. At the moment, I can generate an address like /article/23/my-article-title, where 23 is the id of the article. Today on many blogs you can see the date or id in the URLs.. How can I generate a date based URL by type?
/articles/2014/01/22/my-article-title

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Misyagin, 2016-01-04
@alexnotonfire

config/routes.rb

= link_to 'Моя статья', date_url_path(:day=> day, :month => month, :year => year, :title => title)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question