Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4: Show SQL in console in production [duplicate]

Tags:

After upgrading to rails 4 the executed SQL is no longer shown when I execute commands in the rails console on my server in production. How can I enable that again, without hurting the performance?

like image 967
Niels Kristian Avatar asked Dec 05 '13 12:12

Niels Kristian


People also ask

What is the console in rails?

As a Rails developer, you’ll end up spending a lot of time in the Rails console. It’s like a back door to your application. Using the console lets you interact with parts of your app directly from a command-line interface without going through a browser.

How to run the rails console in RubyMine?

To run the Rails console in RubyMine, perform the steps below: 1 Do one of the following:#N#Press Ctrl twice and type the question mark in a popup. Then, find the rails c command in a... 2 (Optional) In the invoked dialog, select the required environment and press OK. More ...

How does the rails development environment work?

The Rails development environment is streamlined for rapid feedback. You can make code changes in your favorite code editor, then hit Reload in your browser to quickly see the effect of those changes. This works because your application code is automatically reloaded on every request when you’re running in the development environment.

How to explain a category in rails 4?

There is the .explain method in Rails 4. Category.includes (:products).explain => EXPLAIN for: SELECT "categories".* FROM "categories" 0|0|0|SCAN TABLE categories EXPLAIN for: SELECT "categories_products".*


1 Answers

ActiveRecord::Base.logger = Logger.new(STDOUT) 

Execute it in rails console on your server, and then all the ActiveRecord generated SQL queries will be shown.

like image 114
Allerin Avatar answered Oct 31 '22 17:10

Allerin