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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/console_extension.rb', line 12
def
= Community.count
if .zero?
puts "\e[31m(!) You have not yet created any communities.\e[0m"
puts 'Create a community by entering:'
puts ''
puts " Community.create(name: 'my community name', host: 'my.site.com')"
puts ' Rails.cache.clear'
puts ''
if Rails.env.development?
begin
port = Rails::Server::Options.new.parse!(ARGV)[:Port] || 3000
rescue
port = 3000
end
puts "Since you are running in development mode, you probably want to set host to localhost:#{port}"
puts ''
elsif Rails.env.production?
puts 'Since you are running in production mode, set host to your fully qualified domain name without http(s).'
puts 'For example, if you host your site at https://meta.codidact.org, set host to meta.codidact.org'
puts ''
end
puts 'For more information, see the set up instructions.'
elsif == 1
= Community.first
RequestContext. =
puts "\e[32m(!) Found one community, set current community to #{.name} @ #{.host}\e[0m"
else
= Community.find_by(host: 'localhost:3000') if Rails.env.development?
||= Community.first
RequestContext. =
puts "\e[32m(!) Found multiple communities, set current community to #{.name} @ #{.host}\e[0m"
puts ''
puts 'You can change your current community by entering:'
puts ''
puts ' RequestContext.community = Community.find_by(...)'
puts ''
puts "You can use `host: 'my.host'` or `name: 'community name'` in place of the dots"
end
puts ''
rescue
puts "\e[31m(!) Unable to load communities. Is your database configuration correct?\e[0m"
end
|