def load_user user = User.where(email: 'firstname.lastname@example.org') console.log "User: ", user user end
Open your browser's developer console.
(optional) Scream with delight!
gem "console.log"to your Gemfile.
gem "console.log" # makes console.log available in ruby
See the full documentation for console.log, which shows you how to use colour and various other formatting tweaks.
If you want a little yellow triangle beside your message, call
console.warn instead of
If you want your text to be bright red, call
console.error instead of
I wrote it to solve 2 problems:
- It's hard to use rails logs for debugging because they're noisy, or (if you use something like pow)
completely hidden. Using
console.loglets you easily see only log messages in this request.
- When working on the js for Bugsnag I kept accidentally typing
console.loginto Rails. Now that works!
console.log is licensed under the MIT license, see LICENSE.MIT for details.
Contributions and Bug Reports welcome!