Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Because API only Rails Apps don't need no cookies!
# https://github.com/rails-api/rails-api/issues/72
# https://github.com/rails/rails/blob/v5.2.3/railties/lib/rails/application.rb#L579
Rails::Application.class_eval do
if defined?(::Rails.logger)
Rails.logger.warn '[initializers][AA_rails_hacks] - Patching Rails Application class'
else
puts '[initializers][AA_rails_hacks] - Patching Rails Application class'
end
def secret_key_base
if Rails.env.development? || Rails.env.test? || config.api_only == true
secrets.secret_key_base ||= generate_development_secret
else
validate_secret_key_base(
ENV["SECRET_KEY_BASE"] || credentials.secret_key_base || secrets.secret_key_base
)
end
end
def env_config
@app_env_config ||= begin
validate_secret_key_config! unless config.api_only == true
super.merge(
"action_dispatch.parameter_filter" => config.filter_parameters,
"action_dispatch.redirect_filter" => config.filter_redirect,
"action_dispatch.secret_token" => secrets.secret_token,
"action_dispatch.secret_key_base" => secrets.secret_key_base,
"action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,
"action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local,
"action_dispatch.logger" => Rails.logger,
"action_dispatch.backtrace_cleaner" => Rails.backtrace_cleaner,
"action_dispatch.key_generator" => key_generator,
"action_dispatch.http_auth_salt" => config.action_dispatch.http_auth_salt,
"action_dispatch.signed_cookie_salt" => config.action_dispatch.signed_cookie_salt,
"action_dispatch.encrypted_cookie_salt" => config.action_dispatch.encrypted_cookie_salt,
"action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt,
"action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer,
"action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.