运行ruby cli文件时,我的输出包括以下行:
In [39]: X.shape
Out[39]: (10,)
In [40]: y.shape
Out[40]: (10,)
我从其他示例项目中为我的环境,Gemfile和Rakefile复制了内容,显然已经设置了一些输出内容。如何关闭它?
我的gemfile:
D, [2018-11-17T15:33:29.481676 #45237] DEBUG -- : Patient Load (0.6ms) SELECT "patients".* FROM "patients"
我的rakefile:
source "https://rubygems.org"
gem 'pry'
gem 'pry-rescue'
gem 'pry-stack_explorer'
gem 'pry-nav'
gem 'activesupport'
gem 'nokogiri'
gem "activerecord"
gem "sinatra-activerecord"
gem "sinatra"
gem "sqlite3"
gem "rake"
gem "database_cleaner"
group :test do
gem 'poltergeist'
gem 'capybara'
gem 'rspec'
end
我的环境:
# ENV['SINATRA_ENV'] ||= "development"
$LOADED_FEATURES << 'fake/active_support/core_ext/hash'
require_relative './config/environment'
require 'sinatra/activerecord/rake'
task :console do
Pry.start
end
答案 0 :(得分:1)
活动记录默认在开发模式下记录sql输出。要禁用它, 尝试在此部分之后的部分之前添加此行
ActiveRecord::Base.logger = nil
ActiveRecord::Base.establish_connection(
adapter: "sqlite3",
database: "db/#{ENV['SINATRA_ENV']}.sqlite"
)