I've tried adding this in application.rb
config.action_controller.default_url_options = { :trailing_slash => true }
as well as having :trailing_slash => true
in routes.rb
match '/download', to: 'welcome#download', via: 'get', :trailing_slash => true
But neither seems to work. I searched through rails 4.0 doc but couldn't find related info. What am I missing here?
Update:
I've tried adding
Rails.application.default_url_options[:trailing_slash] = true
in filter_parameter_logging.rb
since this is the only place in the whole project where I could find Rails.application.*
, but it's not working either. I found the line here among the releases and I am using 4.0.4. Am I adding this in the wrong place? And I did restarted server before rechecking.
And sorry for the simple question but from what I've gathered isn't trailing_slash
supposed to be reflected in browser url as well, if not primarily? Because this is what I need, to go with historyjs.
I think you have the meaning of :trailing_slash => true
wrong.
All it does is add the / to the end of you path helpers. No redirecting involved.
Your routes will still respond to both with and without the trailing slash.
If you want to redirect all non-trailing_slash
uri's like /download
to /download/
using a nginx http server you would do something like this:
rewrite ^([^.\?]*[^/])$ $1/ permanent;
You would still want to add the :trailing_slash => true
to your routes so your path/url helpers generate the the correct uri's (so user don’t need to redirect).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With