加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Paperclip:与邮箱宝石的集成

发布时间:2020-12-17 02:13:56 所属栏目:百科 来源:网络整理
导读:我正在使用 mailboxer gem,我不知道如何使用Paperclip(Message Class). 将Paperclip与User类一起使用是: class User ActiveRecord::Base has_attached_file :pictureend 如何将has_attached_file添加到Message类(模型中没有message.rb)? 谢谢. 解决方法 两
我正在使用 mailboxer gem,我不知道如何使用Paperclip(Message Class).

将Paperclip与User类一起使用是:

class User < ActiveRecord::Base
  has_attached_file :picture
end

如何将has_attached_file添加到Message类(模型中没有message.rb)?

谢谢.

解决方法

两种解决方案

>使用用carrierwave制造的内置附件(source)
>猴子补丁消息模型:

在初始化程序中执行:

Message.class_eval do

  #your paperclip code goes here

end

别忘了migrations!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读