diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index eb4af72d7..3e5477140 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,6 +5,12 @@ class ApplicationController < ActionController::Base after_action :set_feature_headers def set_ruby_version + if params[:version] == "current" + permitted_params = params.permit(:object, :engine, :q, :page, :theme) + redirect_to permitted_params.merge(version: RubyConfig.default_ruby_version.version) + return + end + version = RubyConfig.version_for(params[:version]) || RubyConfig.default_ruby_version Current.ruby_version = version diff --git a/config/routes.rb b/config/routes.rb index afc5260bc..57b5d5db4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,7 +8,7 @@ ruby_versions = RubyConfig.ruby_versions.collect { |v| Regexp.escape(v.version) } - scope "(:version)", constraints: { version: /#{ruby_versions.join("|")}/ } do + scope "(:version)", constraints: { version: /#{ruby_versions.join("|")}|current/ } do root to: "home#index", as: :versioned_root post '/set_theme', to: 'home#set_theme' # We need the search path to be prefixed with `o/` so that the RDOc links will