1

我有一个使用 Paperclip 4.3.2 的 Rails 4 应用程序。我的模型中指定了以下内容:

    validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/, :message => "some message"

当我尝试加载错误的文件时,我希望找到消息“一些消息”,但我收到了消息:

缺少头像翻译:ca.activerecord.errors.models..attributes.avatar.spoofed_media_type

知道这里出了什么问题吗?

4

1 回答 1

2
validates_attachment :avatar,
  content_type: { content_type: /\Aimage\/.*\Z/, message: "Some Message" }

很好的参考


为了给你一些关于Avatar translation missing错误的背景信息——这通常是由于缺乏I18n翻译造成的......

# config/locales/[[lang]].yml
ca:
  activerecord:
    errors:
      models:
         attributes:
           spoofed_media_type: "Message"

应该会给你一些见解。


最后,“欺骗媒体类型”错误通常意味着您的系统上没有file(或等效的)。我只能从 Windows 经验说起;file如果您没有安装,则需要单独DevKit设置。

于 2016-01-25T10:46:44.900 回答