Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the colors of output in rails console and Rails server log mean?

I'm running rails server and rails console in Ubuntu 14.04 inside the generic terminal (app is just called "Terminal").

Whenever I run commands that involve the database, the console outputs which SQL query it sent but sometimes the text a turquoise color and sometimes it's a purple color. For example in this console output:

2.2.2 :025 >   pl = ProjectLevel.find_by(name: 'Premium')

ProjectLevel Load (0.5ms)  SELECT  "project_levels".* FROM "project_levels" WHERE "project_levels"."deleted_at" 
IS NULL AND "project_levels"."name" = $1 LIMIT 1  [["name", "Premium"]]

=> #<ProjectLevel id: 1, name: "Premium", deleted_at: nil, created_at: "2015-07-15 15:45:40", updated_at: "2015-07-15 15:45:40"> 

(The colors that show up on here are not the same as my console)

The part that says ProjectLevel Load (0.5ms) will sometimes be turqoise but will sometimes be purple but every other part of the text is. Does this color actually mean anything? Is it telling me something about the success of the query or the data returned? Usually things like this in Rails are pretty intuitive (like when a test suite returns green text vs red text to tell you if the tests were successful) but I can't seem to find anything about where those colors are coming from

like image 319
StephanieS Avatar asked Jul 15 '15 16:07

StephanieS


1 Answers

In Rails 5, the colors indicate the type of query:

  • Blue for selects

    enter image description here

  • Yellow for updates

    enter image description here

  • Green for inserts

    enter image description here

  • Red for deletes

    enter image description here

In addition to various other colors for things like alter table or begin/commit statements.


Prior to Rails 5, the colors don't mean anything. They just alternate back and forth so you can easily tell where one query stops and the next query begins.

10.times { Photo.all } yields:

enter image description here

like image 95
meagar Avatar answered Oct 19 '22 23:10

meagar