I am looking to do something similar a wordpress slug where I have a URL like this while maintaining RESTful routing:
http://foo.com/blog/2009/12/04/article-title
The reason I am interested in keep RESTFUL routing is that I am unable to use many plugins because I am using custom routes.
I have already done the RESTful appearance with:
map.connect '/blog/:year/:mon/:day/:slug',
:controller => 'posts', :action => 'show',
:year => /\d{4}/, :month => /\d{2}/,
:day => /\d{2}/, :slug => /.+/,
:requirements => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/, :slug => /.+/ }
In order to write the links, I had to write custom link_to helpers to generate the proper URLs. I really would like to make this RESTful and have the link_to post_path( @post ) yield the URL above and the link_to edit_post_path(@post) ...article-title/edit
I also have :has_many => [:comments] and I would that to work as well. The link_to that I have tried looks like this:
'posts', :action => 'show', :year => recent_post.datetime.year.to_s,
:month => sprintf('%.2d', recent_post.datetime.mon.to_i),
:day => sprintf('%.2d', recent_post.datetime.mday.to_i),
:slug => recent_post.slug %>
and yields this (which isn't what I want):
http://foo.com/posts/show?day=30&month=11&slug=welcome-to-support-skydivers&year=2009
I'm not sure what I am doing wrong. Is it even possible to accomplish this?