PutsJS

Love Ruby’s ‘puts’ syntax? Hate typing ‘console.log’ everytime you want to print something to the web-browser’s console from your Coffecript? Then use putsjs in your rails application. putsjs is a simple gem that allows browser console logging statements to be written as puts statements in your coffescript files and during asset compilation converts them into console.log statements.

Installation

  1. Add PutsJS to your Gemfile:

    gem 'putsjs'
    
  2. Change directory to your Rails app root and Run bundle installer to install PutsJS:

    bundle install
    

Usage

In your coffescript files just use puts followed by any valid statement to log the statement to the browser’s console.

Example:

  • puts “Rails is awesome!”

  • puts this