4

I just updated my blog to Rails 4 from 3. I have a catch all route pattern:

get ':year/:month/:permalink' => 'posts#show'

So routes look like this:

/2012/02/blog_permalink

That works fine, but if I add a forward slash, I get:

No route matches [GET] "/2012/02/blog_permalink/"

I can't seem to figure this one out? I've tried adding a "/" to the end of the route and using :trailing_slash => true. But both of those didn't help.

kush
  • 16,408
  • 17
  • 48
  • 65
  • I have same trouble. See [current answer](http://stackoverflow.com/questions/6482693/how-to-generate-links-with-trailing-slash-in-rails-3) for rails 3 ... :) – Awea Mar 04 '14 at 23:40
  • i just tried that in my rails4 application and it works perfectly. can you please post your complete routes file? – phoet Mar 05 '14 at 02:53
  • 2
    https://github.com/rails/rails/issues/13369 use stable versions :) – amenzhinsky Mar 05 '14 at 15:45

2 Answers2

2

From my perspective it's looks like best solution for this issue till it fixed on rails side are remove trailing slash using rewrite rule on server side. After this issue will be gone, you'll just remove unnecessary config line from server configuration.

Sergey Moiseev
  • 2,953
  • 2
  • 24
  • 28
-1

In Application.rb, set this line :

config.action_controller.default_url_options = { trailing_slash: true }
sidney
  • 2,704
  • 3
  • 28
  • 44