Use secret_key_base as paperclip hash_secret
Rails 4 declares in constants config/secrets.yml
secret_key_base
to "verify the integrity of signed cookies". Abstracts are 128 characters long (0..f).
Folder (file management) can use the option :hash_secret
to encode the access file names.
https://github.com/thoughtbot/paperclip/wiki/Hashing
Is there a good idea to use secret_key_base
both Paperclip hashes? This seems to be a good solution because it is quite complex, it is not executed in the project and has one for the environment.
Declare 2 variables in secrets.yml
will look like this:
development:
secret_key_base: 73512
secret_key_asset: 123456
test:
secret_key_base: 3dde2
secret_key_asset: 789456
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
secret_key_asset: <%= ENV["SECRET_KEY_ASSET"] %>
... It seems that nothing is difficult for me.
Hello
source to share
According to this excerpt from the Paperclip Wiki, it would appear that secret_key_base is fine.
# config/initializers/paperclip_defaults.rb
Paperclip::Attachment.default_options.update({
url: "/system/:class/:attachment/:id_partition/:style/:hash.:extension",
hash_secret: Rails.application.secrets.secret_key_base
})
You can use a different secret key for Paperclip, but it probably isn't needed for most projects.
source to share