How to determine if Rails is running from CLI, console or as server?
Peeking at the Rails module using pry reveals that console invocations can be detected like this: Rails.const_defined? ‘Console’ And server invocations like this: Rails.const_defined? ‘Server’