I have an app that has a Post
model. We publish lots of reports, and we consider each report a Post
. This app was migrated from a legacy PHP system, so I did some Ruby-fu in my routes.rb
to handle and translate those legacy requests and redirect them to the right place. That is done like this:
get '/:friendly_id', to: 'posts#show'
get '/rbt/:name', to: redirect {|path_params, _| "/#{path_params[:name].gsub(/^\d+\-/, '')}" }
get ':name', to: 'posts#show'
Note though that due to both friendly_id
and that last route, pretty much all requests get sent to the Post#Show
action.
I have now just added a blog, powered by MiddleMan. MiddleMan generates static HTML files at build time, and then copies them to my public/blog
directory.
The issue is that now, all requests to /blog/2015/03/01....
are intercepted by my routes.rb
, so whenever I try to navigate to a blog post, I get a routing error like this:
No route matches [GET] "/blog/2015/03/11/hello_world"
What’s the best way to approach this?