{"id":13428047,"url":"https://github.com/rails/web-console","last_synced_at":"2025-10-04T19:31:14.059Z","repository":{"id":10357376,"uuid":"12496351","full_name":"rails/web-console","owner":"rails","description":"Rails Console on the Browser.","archived":false,"fork":true,"pushed_at":"2024-12-19T09:23:26.000Z","size":1104,"stargazers_count":1402,"open_issues_count":13,"forks_count":178,"subscribers_count":39,"default_branch":"main","last_synced_at":"2025-01-22T07:03:58.143Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"gsamokovarov/web-console","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rails.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGELOG.markdown","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-30T21:57:37.000Z","updated_at":"2025-01-17T05:45:24.000Z","dependencies_parsed_at":"2023-01-16T19:15:39.783Z","dependency_job_id":null,"html_url":"https://github.com/rails/web-console","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rails%2Fweb-console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rails%2Fweb-console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rails%2Fweb-console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rails%2Fweb-console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rails","download_url":"https://codeload.github.com/rails/web-console/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235246399,"owners_count":18959223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T01:00:44.903Z","updated_at":"2025-10-04T19:31:08.995Z","avatar_url":"https://github.com/rails.png","language":"Ruby","readme":"\u003cp align=right\u003e\n  \u003cstrong\u003eCurrent version: 4.2.1\u003c/strong\u003e | Documentation for:\n  \u003ca href=https://github.com/rails/web-console/tree/v1.0.4\u003ev1.0.4\u003c/a\u003e\n  \u003ca href=https://github.com/rails/web-console/tree/v2.2.1\u003ev2.2.1\u003c/a\u003e\n  \u003ca href=https://github.com/rails/web-console/tree/v3.7.0\u003ev3.7.0\u003c/a\u003e\n\u003c/p\u003e\n\n# Web Console [![CI](https://github.com/rails/web-console/actions/workflows/ci.yml/badge.svg)](https://github.com/rails/web-console/actions/workflows/ci.yml)\n\n_Web Console_ is a debugging tool for your Ruby on Rails applications.\n\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Usage](#usage)\n- [FAQ](#faq)\n- [Credits](#credits)\n\n## Installation\n\nAdd the following to your `Gemfile`:\n\n```ruby\ngroup :development do\n  gem 'web-console'\nend\n```\n\n## Usage\n\nThe web console allows you to create an interactive Ruby session in your\nbrowser. Those sessions are launched automatically in case of an error and can\nalso be launched manually in any page.\n\nFor example, calling `console` in a view will display a console in the current\npage in the context of the view binding.\n\n```html\n\u003c% console %\u003e\n```\n\nCalling `console` in a controller will result in a console in the context of\nthe controller action:\n\n```ruby\nclass PostsController \u003c ApplicationController\n  def new\n    console\n    @post = Post.new\n  end\nend\n```\n\nThe method is defined in `Kernel` and you can invoke it any application code.\n\nOnly one `console` invocation per request is allowed. If you happen to\nhave multiple ones, `WebConsole::DoubleRenderError` will be raised.\n\n## Configuration\n\n_Web Console_ allows you to execute arbitrary code on the server. Therefore, be\nvery careful who you give access to.\n\n### config.web_console.permissions\n\nBy default, only requests coming from IPv4 and IPv6 localhosts are allowed.\n\n`config.web_console.permissions` lets you control which IP's have access to\nthe console.\n\nYou can allow single IP's or whole networks. Say you want to share your\nconsole with `192.168.0.100`:\n\n```ruby\nclass Application \u003c Rails::Application\n  config.web_console.permissions = '192.168.0.100'\nend\n```\n\nIf you want to allow the whole private network:\n\n```ruby\nRails.application.configure do\n  config.web_console.permissions = '192.168.0.0/16'\nend\n```\n\nTake a note that IPv4 and IPv6 localhosts are always allowed. This wasn't the\ncase in 2.0.\n\n### config.web_console.whiny_requests\n\nWhen a console cannot be shown for a given IP address or content type,\nmessages such as the following is printed in the server logs:\n\n\u003e Cannot render console from 192.168.1.133! Allowed networks:\n\u003e 127.0.0.0/127.255.255.255, ::1\n\nIf you don't want to see this message anymore, set this option to `false`:\n\n```ruby\nRails.application.configure do\n  config.web_console.whiny_requests = false\nend\n```\n\n### config.web_console.template_paths\n\nIf you want to style the console yourself, then you can place `style.css` at a\ndirectory pointed by `config.web_console.template_paths`:\n\n```ruby\nRails.application.configure do\n  config.web_console.template_paths = 'app/views/web_console'\nend\n```\n\nYou may want to check the [templates] folder at the source tree for the files you\nmay override.\n\n### config.web_console.mount_point\n\nUsually the middleware of _Web Console_ is mounted at `/__web_console`.\nIf there is a need to change the path, then you can specify it by\n`config.web_console.mount_point`:\n\n```ruby\nRails.application.configure do\n  config.web_console.mount_point = '/path/to/web_console'\nend\n```\n\n## FAQ\n\n### Where did /console go?\n\nThe remote terminal emulator was extracted in its own gem which is no longer\nbundled with _Web Console_.\n\nIf you miss this feature, check out [rvt].\n\n### Why do I constantly get unavailable session errors?\n\nAll of _Web Console_ sessions are stored in memory. If you happen to run on a\nmulti-process server (like Unicorn), you may encounter unavailable session errors\nwhile the server is still running. This is because a request may hit a\ndifferent worker (process) that doesn't have the desired session in memory.\nTo avoid that, if you use such servers in development, configure them so they\nserve requests only out of one process.\n\n#### Passenger\n\nEnable sticky sessions for [Passenger on Nginx] or [Passenger on Apache] to\nprevent unavailable session errors.\n\n### How to inspect local and instance variables?\n\nThe interactive console executes Ruby code. Invoking `instance_variables` and\n`local_variables` will give you what you want.\n\n### Why does the console only appear on error pages but not when I call it?\n\nThis can be happening if you are using `Rack::Deflater`. Be sure that\n`WebConsole::Middleware` is used after `Rack::Deflater`. The easiest way to do\nthis is to insert `Rack::Deflater` as early as possible\n\n```ruby\nRails.application.configure do\n  config.middleware.insert(0, Rack::Deflater)\nend\n```\n\n### Why am I getting an undefined method `web_console`?\n\nMake sure your configuration lives in `config/environments/development.rb`.\n\n## Credits\n\n* Shoutout to [Hailey Somerville] for [better_errors].\n* Kudos to [John Mair] for [binding_of_caller] and [debug_inspector].\n* Thanks to [Charles Oliver Nutter] for all the _JRuby_ feedback.\n* Hugs and kisses to all of our [contributors]!\n\n[better_errors]: https://github.com/BetterErrors/better_errors\n[debug_inspector]: https://github.com/banister/debug_inspector\n[binding_of_caller]: https://github.com/banister/binding_of_caller\n[Hailey Somerville]: https://github.com/haileys\n[John Mair]: https://github.com/banister\n[Charles Oliver Nutter]: https://github.com/headius\n[templates]: https://github.com/rails/web-console/tree/main/lib/web_console/templates\n[rvt]: https://github.com/gsamokovarov/rvt\n[contributors]: https://github.com/rails/web-console/graphs/contributors\n[Passenger on Nginx]: https://www.phusionpassenger.com/library/config/nginx/reference/#passengerstickysessions\n[Passenger on Apache]: https://www.phusionpassenger.com/library/config/apache/reference/#passengerstickysessions\n","funding_links":[],"categories":["Debug","Ruby","调试"],"sub_categories":["Omniauth"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frails%2Fweb-console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frails%2Fweb-console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frails%2Fweb-console/lists"}