View Rails debug messages in the browser console with Rconsole
Using log messages in Rails can be a huge timesaver when you are debugging. With Rconsole you can save even more time by having those messages appear in the browser console. Rconsole is a fairly new gem with a lot of potential.
Installation is super simple. First add it to your Gemfile
:
group :development do
gem 'rconsole', '~> 0.1.0'
end
Then run bundle install
. Add to your layout view:
javascript_include_tag(:rconsole) if Rails.env.development?
To use Rconsole simply add rconsole.log
messages where you would normally insert logger.debug
, etc.
def show
rconsole.log 'Hello, Changeloggers!'
...
end
Now your browser will display your messages:
In addition to debugging, Rconsole is particularly useful when working with students or new rubyists to show the connection between what's happening in the controller and the view.
The entire code base is open source and available on GitHub.
Discussion
Sign in or Join to comment or subscribe