Git Product home page Git Product logo

web-console's Introduction

Documentation for: v0.1.0 v0.2.0 v0.3.0 v0.4.0 v1.0.4

Web Console Build Status

Web Console is a set of debugging tools for your Rails application.

A debugging tool in the default error page.

An interactive console is launched automatically in the default Rails error page. It makes it easy to inspect the stack trace and execute Ruby code in the stack trace's bindings.

(Check out better_errors as a great alternative for any Rack application!)

image

A debugging tool in your controllers and views.

Drop <%= console %> anywhere in a view to launch an interactive console session and execute code in it. Drop console anywhere in a controller and do the same in the context of the controller action.

image

Requirements

Web Console has been tested on the following rubies.

  • MRI Ruby 2.1.0
  • MRI Ruby 2.0.0
  • MRI Ruby 1.9.3

There is an experimental JRuby 1.7 support. See Installation section for more information.

Web Console is built explicitly for Rails 4.

Installation

To install it in your current application, add the following to your Gemfile.

group :development do
  gem 'web-console', '~> 2.0'
end

If you are running JRuby, you can get experimental support with adding a pre-release version of binding_of_caller.

group :development do
  gem 'web-console', '~> 2.0'

  gem 'binding_of_caller', '0.7.3.pre1'
end

After you save the Gemfile changes, make sure to run bundle install and restart your server for the Web Console to kick in.

Configuration

Today we have learned in the agony of war that great power involves great responsibility.

-- Franklin D. Roosevelt

Web Console is a powerful tool. It allows you to execute arbitrary code on the server, so you should be very careful, who you give access to it.

config.web_console.whitelisted_ips

By default, only requests coming from 127.0.0.1 are allowed.

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

Let's 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 = %w( 127.0.0.1 192.168.0.100 )
end

From the example, you can guess that config.web_console.whitelisted_ips accepts an array of ip addresses, provided as strings. An important thing to note here is that, we won't push 127.0.0.1 if you manually set the option!

If you want to whitelist a whole network, you can do:

class Application < Rails::Application
  config.web_console.whitelisted_ips = '192.168.0.0/16'
end

Again, note that this network doesn't allow 127.0.0.1. If you want to access the console, you have to do so from it's external IP or add 127.0.0.1 to the mix.

Credits

FAQ

I'm running JRuby and there's no console on the default error page.

You would also have to run you Rails server in JRuby's interpreted mode. Enable it with code snippet below, then start your development Rails server with rails server, as usual.

export JRUBY_OPTS=-J-Djruby.compile.mode=OFF

# If you run JRuby 1.7.12 and above, you can use:
# export JRUBY_OPTS=--dev

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.

web-console's People

Contributors

gsamokovarov avatar ryandao avatar guilleiguaran avatar stanangeloff avatar jonatack avatar rafaelfranca avatar bronzle avatar rosenfeld avatar bglbruno avatar oppegard avatar jeffnv avatar joshk avatar matiaskorhonen avatar pabloformoso avatar pete-a avatar jasonl99 avatar

Watchers

James Cloos 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.