class Ecrire::Application
Ecrire::Application
is the entry point when running a blog.
The big difference between this application and a normal Rails application is that Ecrire
will look for secrets.yml
in the current working directory.
If it doesn't find one, it will load the Onboarding
process so the user can configure the database and the first user.
If the application finds secrets.yml
, it will load the Theme
which is located in the current working directory.
Attributes
pwd[W]
Public Class Methods
onboarding?()
click to toggle source
Returns true if Ecrire::Onboarding::Engine
is loaded in the application runtime
# File lib/ecrire/application.rb, line 94 def onboarding? secrets.fetch(:onboarding, true) end
Public Instance Methods
config()
click to toggle source
# File lib/ecrire/application.rb, line 84 def config @config ||= Ecrire::Configuration.new(Pathname.new(self.class.called_from)) end
secrets()
click to toggle source
Override Rails secrets management as it doesn't allow us to do what we want. Then, Ecrire
will merge anything that is through environment variables
# File lib/ecrire/application.rb, line 59 def secrets @secrets ||= begin secrets = ActiveSupport::OrderedOptions.new yaml = config.paths["config/secrets"].first if File.exist?(yaml) require "erb" content = YAML.load(ERB.new(IO.read(yaml)).result) || {} secrets.merge!(content.deep_symbolize_keys) end if ENV.has_key?(Ecrire::SECRET_ENVIRONMENT_KEY) require 'json' secrets.merge!(JSON.parse(ENV[Ecrire::SECRET_ENVIRONMENT_KEY]).deep_symbolize_keys) end # Fallback to config.secret_key_base if secrets.secret_key_base isn't set secrets.secret_key_base ||= config.secret_key_base # Fallback to config.secret_token if secrets.secret_token isn't set secrets.secret_token ||= config.secret_token secrets end end