Method: DiscoAppGenerator#configure_application

Defined in:
lib/generators/disco_app/disco_app_generator.rb

#configure_applicationObject

Make any required adjustments to the application configuration.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/generators/disco_app/disco_app_generator.rb', line 78

def configure_application
  # The force_ssl flag is commented by default for production.
  # Uncomment to ensure config.force_ssl = true in production.
  uncomment_lines 'config/environments/production.rb', /force_ssl/

  # Set time zone to UTC
  application "config.time_zone = 'UTC'"
  application "# Ensure UTC is the default timezone"

  # Set server side rendereing for components.js
  application "config.react.server_renderer_options = {\nfiles: ['components.js'], # files to load for prerendering\n}"
  application "# Enable server side react rendering"

  # Set defaults for various charge attributes.
  application "config.x.shopify_charges_default_trial_days = 14\n"
  application "config.x.shopify_charges_default_price = 10.00"
  application "config.x.shopify_charges_default_type = :recurring"
  application "# Set defaults for charges created by the application"

  # Set the "real charges" config variable to false explicitly by default.
  # Only in production do we read from the environment variable and
  # potentially have it become true.
  application "config.x.shopify_charges_real = false\n"
  application "# Explicitly prevent real charges being created by default"
  application "config.x.shopify_charges_real = ENV['SHOPIFY_CHARGES_REAL'] == 'true'\n", env: :production
  application "# Allow real charges in production with an ENV variable", env: :production

  # Configure session storage.
  application "ActiveRecord::SessionStore::Session.table_name = 'disco_app_sessions'"
  application "ActionDispatch::Session::ActiveRecordStore.session_class = DiscoApp::Session"
  application "# Configure custom session storage"

  # Set Sidekiq as the queue adapter in production.
  application "config.active_job.queue_adapter = :sidekiq\n", env: :production
  application "# Use Sidekiq as the active job backend", env: :production

  # Ensure the application configuration uses the DEFAULT_HOST environment
  # variable to set up support for reverse routing absolute URLS (needed when
  # generating Webhook URLs for example).
  application "routes.default_url_options[:host] = ENV['DEFAULT_HOST']\n"
  application "# Set the default host for absolute URL routing purposes"

  # Configure React in development and production.
  application "config.react.variant = :development", env: :development
  application "# Use development variant of React in development.", env: :development
  application "config.react.variant = :production", env: :production
  application "# Use production variant of React in production.", env: :production

  # Copy over the default puma configuration.
  copy_file 'config/puma.rb', 'config/puma.rb'

  # Mail configuration
  configuration = "\n      # Configure ActionMailer to use MailGun\n      if ENV['MAILGUN_API_KEY']\n        config.action_mailer.delivery_method = :mailgun\n        config.action_mailer.mailgun_settings = {\n          api_key: ENV['MAILGUN_API_KEY'],\n          domain: ENV['MAILGUN_API_DOMAIN']\n        }\n      end\n  CONFIG\n  application configuration, env: :production\n\n  # Monitoring configuration\n  copy_file 'initializers/rollbar.rb', 'config/initializers/rollbar.rb'\n  copy_file 'config/newrelic.yml', 'config/newrelic.yml'\nend\n".strip_heredoc