简体   繁体   English

向回形针gem添加自定义“样式”

[英]Adding custom “styles” to Paperclip gem

Right now I have this 现在我有这个

has_attached_file :cover_image,
                   styles: { square: "200x200#", small:"400x400>",medium:"500x600" }

I want to have this: 我想要这个:

has_attached_file :cover_image,
                   styles: { thumb: "50x50#", square: "200x200#", small: "400x400>", medium: "500x600" }

When I add the "thumb" key I get a 404 error. 当我添加“拇指”键时,出现404错误。 Is there a way to create a new "style"? 有没有办法创建新的“样式”?

Seems like there is no issue in your code. 似乎您的代码中没有问题。

You might be getting error while fetching previous record's thumb, which is not generated yet. 提取以前的记录的缩略图时可能会出错,但尚未生成。 Try create previous record thumbnail also and your error will gone. 尝试也创建以前的记录缩略图,您的错误将消失。

Run below command in console. 在控制台中运行以下命令。

rake paperclip:refresh CLASS=User ## change User with model name.

More information you can find here . 您可以在此处找到更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM