LoginSignup
2
0

More than 5 years have passed since last update.

uploader内でリザイズ処理を条件分岐

Posted at
hoge_uploader.rb
def filename
  if model.type == 1
    resize_to_limit 1000, 1000
  end    
  "#{secure_token}.#{file.extension}" if original_filename.present?
end

fullname内でmodel.idなどuploaderをmountしたモデルにアクセスできるので
ここでデータの状態に応じた条件を指定できる。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0