ruby-on-railsputs

Rails puts() not creating any output


In what I've tried to make the simplest of examples, I don't get any output from a puts() to the Rails console or to the development.log when ranges#ranges is hit. The ranges.html.erb is rendered as expected. What am I not understanding?

class RangesController < ApplicationController
  def ranges
    puts "the_color_hex"
  end

  def set_color_hex
  end
end

From the tail end of the development.log file:

    Started GET "/ranges" for 127.0.0.1 at 2025-01-22 17:31:49 -0500
Processing by RangesController#ranges as HTML
  Rendering layout layouts/application.html.erb
  Rendering ranges/ranges.html.erb within layouts/application
  Rendered ranges/ranges.html.erb within layouts/application (Duration: 1.9ms | GC: 0.5ms)
  Rendered layout layouts/application.html.erb (Duration: 3.7ms | GC: 0.5ms)
Completed 200 OK in 42ms (Views: 5.0ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.5ms)

Solution

  • barring any silly issues like not saving the file or anything -- keep in mind that puts will write to stdout, not your log file. The output should not be inside of development.log (unless you're doing something non-standard).

    Typically you would see this output in the terminal where you ran the rails server command.

    You could try using logger "hi mom" or Rails.logger "hi mom" to see the message in your development.log file.