Ruby: console.log?

Ruby

Ruby Problem Overview


I recently put console.log statements in every line of a JavaScript program and found that it's now much easier to understand. Is there a way to do that with server side code, specifically Ruby? I presume there's no way to read it in firebug, but would it be visible in irb? what console.log equivalent statements would I put in the Ruby code?

Ruby Solutions


Solution 1 - Ruby

puts is the equivalent in ruby.

Example

puts 'Hello World!'

Solution 2 - Ruby

If you are running your server in the console, you can use puts. Otherwise, you will need to write to a file, possibly via a logger (like Rails.logger.info).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrainLikeADullPencilView Question on Stackoverflow
Solution 1 - RubymashView Answer on Stackoverflow
Solution 2 - RubyDaniel EvansView Answer on Stackoverflow