gpt4 book ai didi

ruby-on-rails - 如何为某些回形针样式添加条件?

转载 作者:数据小太阳 更新时间:2023-10-29 08:13:51 25 4
gpt4 key购买 nike

我有一个名为 Graphic 的模型,每个图形都属于一个名为 Book 的模型,该图形模型有 1 种样式,我想添加第二个名为“dealer_logo”的样式:

:thumb       => ['75x75>],
:dealer_logo => ['200x45>', :jpg], :if => Proc.new {|file| Book.find(self.book_id).origin_id == 33}

我只希望生成 dealer_logo 样式,但是如果 Book.origin_id 等于 33,则我无法使上述代码工作。

谁能给我一些指点?

谢谢

最佳答案

您需要使用自定义处理器: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/processor.rb

By defining a subclass of Paperclip::Processor, you can perform any processing you want on the files that are attached. Any file in your Rails app’s lib/paperclip_processors directory is automatically loaded by paperclip, allowing you to easily define custom processors. You can specify a processor with the :processors option to has_attached_file:

has_attached_file :scan, :styles => { :text => { :quality => :better } },
:processors => [:ocr]

关于ruby-on-rails - 如何为某些回形针样式添加条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4199039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com