diff options
author | Yoshiyuki Hirano <yhirano@me.com> | 2018-11-06 23:20:56 +0900 |
---|---|---|
committer | Yoshiyuki Hirano <yhirano@me.com> | 2018-11-07 08:14:09 +0900 |
commit | b6e4305c3bca4c673996d0af9db0f4cfbf50215e (patch) | |
tree | 989bc8c2df38c557e6bc6a72f308b75f432bd21c /railties/lib | |
parent | 212c28ac86fec0f2baf57fbc21ceb8696092fe47 (diff) | |
download | rails-b6e4305c3bca4c673996d0af9db0f4cfbf50215e.tar.gz rails-b6e4305c3bca4c673996d0af9db0f4cfbf50215e.tar.bz2 rails-b6e4305c3bca4c673996d0af9db0f4cfbf50215e.zip |
Add JSON support to rails properties route (`/rails/info/properties`).
Added json format, like this:
{
"Rails version": "6.0.0.alpha",
"Ruby version": "2.5.1-p57 (x86_64-darwin17)",
"RubyGems version": "2.7.6",
"Rack version": "2.0.6",
"JavaScript Runtime": "Node.js (V8)",
"Middleware": ["Rack::Sendfile", "ActionDispatch::Static", "ActionDispatch::Executor", "ActiveSupport::Cache::Strategy::LocalCache::Middleware", "Rack::Runtime", "Rack::MethodOverride", "ActionDispatch::RequestId", "ActionDispatch::RemoteIp", "Sprockets::Rails::QuietAssets", "Rails::Rack::Logger", "ActionDispatch::ShowExceptions", "WebConsole::Middleware", "ActionDispatch::DebugExceptions", "ActionDispatch::Reloader", "ActionDispatch::Callbacks", "ActiveRecord::Migration::CheckPending", "ActionDispatch::Cookies", "ActionDispatch::Session::CookieStore", "ActionDispatch::Flash", "ActionDispatch::ContentSecurityPolicy::Middleware", "Rack::Head", "Rack::ConditionalGet", "Rack::ETag", "Rack::TempfileReaper"],
"Application root": "/path/to/app",
"Environment": "development",
"Database adapter": "sqlite3",
"Database schema version": 0
}
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/info.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/info_controller.rb | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb index 3df36efc4c..b8173c8d11 100644 --- a/railties/lib/rails/info.rb +++ b/railties/lib/rails/info.rb @@ -54,6 +54,10 @@ module Rails table << "</table>" end end + + def to_json + Hash[properties].to_json + end end # The Rails version. diff --git a/railties/lib/rails/info_controller.rb b/railties/lib/rails/info_controller.rb index b4f4a5922a..50fe176946 100644 --- a/railties/lib/rails/info_controller.rb +++ b/railties/lib/rails/info_controller.rb @@ -14,8 +14,16 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc: end def properties - @info = Rails::Info.to_html - @page_title = "Properties" + respond_to do |format| + format.html do + @info = Rails::Info.to_html + @page_title = "Properties" + end + + format.json do + render json: Rails::Info.to_json + end + end end def routes |