crypt:路由中的basename

时间:2014-02-10 13:12:20

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 paperclip

我正在使用回形针并以下列方式将路径网址设为

has_attached_file :avatar,
  :path => ":rails_root/app/assets/images/:basename.:extension"

问题是我需要加密basename属性,okey rails有一个函数crypt,但是如何将它用于路由,如下所示:

has_attached_file :avatar,
  :path => ":rails_root/app/assets/images/#{:basename.crypt('key')}.:extension"

1 个答案:

答案 0 :(得分:0)

看看是否有效

has_attached_file :avatar,
  :path => ":rails_root/app/assets/images/#{Paperclip::Interpolations.basename.crypt('key')}.:extension"