Coder Social home page Coder Social logo

web-console's Introduction

Documentation for: v1.0.4 v2.2.1

Web Console Build Status

Web Console is a debugging tool for your Ruby on Rails applications.

Installation

Add the following to your Gemfile.

group :development do
  gem 'web-console'
end

Usage

The web console allows you to create an interactive Ruby session in your browser. Those sessions are launched automatically in case of an error, but they can also be launched manually in any page.

For example, calling console in a view will display a console in the current page in the context of the view binding.

<% console %>

Calling console in a controller will result in a console in the context of the controller action:

class PostsController < ApplicationController
  def new
    console
    @post = Post.new
  end
end

The method is defined in Kernel and you can invoke it any application code.

Only one console invocation per request is allowed. If you happen to have multiple ones, WebConsole::DoubleRenderError will be raised.

Configuration

Web Console allows you to execute arbitrary code on the server, so you should be very careful, who you give access to.

config.web_console.whitelisted_ips

By default, only requests coming from IPv4 and IPv6 localhosts are allowed.

config.web_console.whitelisted_ips lets you control which IP's have access to the console.

You can whitelist single IP's or whole networks. Say you want to share your console with 192.168.0.100. You can do this:

class Application < Rails::Application
  config.web_console.whitelisted_ips = '192.168.0.100'
end

If you want to whitelist the whole private network, you can do:

Rails.application.configure do
  config.web_console.whitelisted_ips = '192.168.0.0/16'
end

Take a note that IPv4 and IPv6 localhosts are always allowed. This wasn't the case in 2.0.

config.web_console.whiny_requests

When a console cannot be shown for a given IP address or content type, a messages like the following is printed in the server logs:

Cannot render console from 192.168.1.133! Allowed networks: 127.0.0.0/127.255.255.255, ::1

If you don't wanna see this message anymore, set this option to false:

Rails.application.configure do
  config.web_console.whiny_requests = false
end

config.web_console.template_paths

If you wanna style the console yourself, you can place style.css at a directory pointed by config.web_console.template_paths:

Rails.application.configure do
  config.web_console.template_paths = 'app/views/web_console'
end

You may wanna check the templates folder at the source tree for the files you may override.

config.web_console.mount_point

Usually the middleware of Web Console is mounted at /__web_console. If you wanna change the path for some reasons, you can specify it by config.web_console.mount_point:

Rails.application.configure do
  config.web_console.mount_point = '/path/to/web_console'
end

FAQ

Where did /console go?

The remote terminal emulator was extracted in its own gem that is no longer bundled with Web Console.

If you miss this feature, check out rvt.

Why I constantly get unavailable session errors?

All of Web Console sessions are stored in memory. If you happen to run on a multi-process server (like Unicorn) you may get unavailable session errors while the server is still running. This is because a request may hit a different worker (process) that doesn't have the desired session in memory. To avoid that, if you use such servers in development, configure them so they server requests only out of one process.

How to inspect local and instance variables?

The interactive console executes Ruby code. Invoking instance_variables and local_variables will give you what you want.

Why does console only appear on error pages but not when I call it?

This can be happening if you are using Rack::Deflater. Be sure that WebConsole::Middleware is used after Rack::Deflater. The easiest way to do this is to insert Rack::Deflater as early as possible

Rails.application.configure do
  config.middleware.insert(0, Rack::Deflater)
end

Why I'm getting an undefined method web_console?

Make sure your configuration lives in config/environments/development.rb.

Credits

web-console's People

Contributors

akirakoyasu avatar amatsuda avatar bronzle avatar chibicode avatar dreyks avatar eileencodes avatar gsamokovarov avatar guilleiguaran avatar haileys avatar herminiotorres avatar jasonl99 avatar jeroenvisser101 avatar jmbejar avatar jonatack avatar joshk avatar matiaskorhonen avatar matthewd avatar noahpatterson avatar pabloformoso avatar paulanunda avatar pete-a avatar rafaelfranca avatar rakvium avatar rosenfeld avatar ryandao avatar sh19910711 avatar stanangeloff avatar voxik avatar xijo avatar y-yagi avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.