Rails Routes - How to make them case insensitive?

后端 未结 6 472
春和景丽
春和景丽 2021-01-17 18:10

Routes in Ruby on Rails are case sensitive. It seems someone brought this up before, and it has been labeled will not fix.

http://rails.lighthouseapp.com/projects/89

6条回答
  •  北海茫月
    2021-01-17 18:15

    just monkey-patch it to downcase by default. simple example:

    module ActionController
      module Caching
        module Pages
          def cache_page(content = nil, options = nil)
            return unless perform_caching && caching_allowed
    
            path = case options
              when Hash
                url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format]))
              when String
                options
              else
                request.path
            end
    
            path = path.downcase
    
            self.class.cache_page(content || response.body, path)
          end
        end
      end
    end
    

提交回复
热议问题