Answer the question
In order to leave comments, you need to log in
How to write SQL queries to the database in Rails, to a separate file?
Good afternoon. In my rail project, it became necessary to write sql queries to the database, in a separate file. All requests are written to the railsav log file, but absolutely everything is written there. I'm not so comfortable.
Has anyone done this, any ideas?
Answer the question
In order to leave comments, you need to log in
Write your own logger
ruby-doc.org/stdlib-2.0.0/libdoc/logger/rdoc/Logge...
I'll expand on the above answer a bit.
guides.rubyonrails.org/configuring.html
For example, in order to log SQL queries to a file, you need to write such a line, for example, in config/application.rb.
config.active_record.logger = Logger.new(Rails.root.join('log', 'sql.log'))
in general, in dev mode, queries to the database and so are written to the log
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question