-
Notifications
You must be signed in to change notification settings - Fork 1
/
.pryrc
36 lines (28 loc) · 954 Bytes
/
.pryrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Pry.config.pager = false
Pry.config.prompt = [proc { ">> " },
proc { " | " }]
Pry.config.prompt_name = (ENV['USER'] || "pry")
if ENV['RAILS_ENV'] || defined?(Rails)
def sql(query)
ActiveRecord::Base.connection.select_all(query)
end
require 'logger'
if defined?(Rails) && Rails.respond_to?(:logger=)
tagged_logger = defined?(ActiveSupport::TaggedLogging) && Rails.logger.is_a?(ActiveSupport::TaggedLogging)
Rails.logger = Logger.new(STDOUT)
Rails.logger = ActiveSupport::TaggedLogging.new(Rails.logger) if tagged_logger
defined?(ActiveRecord) && ActiveRecord::Base.logger = Rails.logger
else
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
end
def loud_logger
set_logger_to Logger.new(STDOUT)
end
def quiet_logger
set_logger_to nil
end
def set_logger_to(logger)
ActiveRecord::Base.logger = logger
ActiveRecord::Base.clear_active_connections!
end
end