Class: Recipes::Rails

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/potassium/recipes/rails.rb

Instance Method Summary collapse

Instance Method Details

#createObject



2
3
4
5
6
7
8
# File 'lib/potassium/recipes/rails.rb', line 2

def create
  gather_gem("bootsnap", require: false)
  gather_gem("sassc", github: "sass/sassc-ruby", ref: 'refs/pull/233/head')
  gather_gem("sassc-embedded")
  environment 'config.force_ssl = true', env: 'production'
  disable_automatic_nonce_generation
end

#disable_automatic_nonce_generationObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/potassium/recipes/rails.rb', line 10

def disable_automatic_nonce_generation
  line = "Rails.application.config.content_security_policy_nonce_generator = \
-> request { SecureRandom.base64(16) }"
  initializer = "config/initializers/content_security_policy.rb"
  gsub_file initializer, /(#{Regexp.escape(line)})/mi do |_match|
    <<~HERE.chomp
      # Rails.application.config.content_security_policy_nonce_generator = -> request do
      #   SecureRandom.base64(16)
      # end
    HERE
  end
end