I use to_param in my application to create a custom URL (this custom path contains slashes):
class Machine < ActiveRecord::Base def to_param MachinePrettyPath.show_path(self, cut_model_text: true) end end
The thing is, since the behavior of Rails 4.1.2 has changed, and Rails does not allow slashes in the URL (when using a custom URL), so it skips slashes.
I had the following routes:
Rails.application.routes.draw do scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do resources :machines, except: :destroy do collection do get :search get 'search/:ad_type(/:machine_type(/:machine_subtype(/:brand)))', action: 'search', as: :pretty_search get ':subcategory/:brand(/:model)/:id', action: 'show', as: :pretty patch ':subcategory/:brand(/:model)/:id', action: 'update'
I tried using the recommendation in the stream to use the glob parameter only for the show method, to make sure that it works:
resources :machines, except: :destroy do
But this is absolutely not working. I still have such broken links:
http://localhost:3000/machines/tractor%2Fminitractor%2Fmodel1%2F405
Of course, if I would replace the hidden slashes with myself:
http://localhost:3000/machines/tractor/minitractor/model1/405
And try visiting the path, then the page will open.
Any ideas how I can fix this?