Ruby on rails 使用曲别针验证内容类型失败

Ruby on rails 使用曲别针验证内容类型失败,ruby-on-rails,paperclip,Ruby On Rails,Paperclip,我正在尝试使用回形针上载.xm文件,该文件应具有mime类型audio/x-mod。 我通过设置以下选项将曲别针配置为允许此配置: Paperclip.options[:content_type_mappings] = { xm: "audio/x-mod" } 附件字段的验证如下所示: validates_attachment :song, presence: true, content_type: { content_type: ["audio/x-mod"] }, siz

我正在尝试使用回形针上载.xm文件,该文件应具有mime类型
audio/x-mod
。 我通过设置以下选项将曲别针配置为允许此配置:

Paperclip.options[:content_type_mappings] = {
    xm: "audio/x-mod"
}
附件字段的验证如下所示:

validates_attachment :song, presence: true,
  content_type: { content_type: ["audio/x-mod"] },
  size: { in: 0..128.kilobytes }
validates_attachment_content_type : song, :content_type => /\Aaudio/
每当我尝试上载mime类型为
audio/x-mod
paperclip的.xm文件时,就会出现错误
歌曲内容类型无效
。 当我将有效的内容类型指定为
[/.+/]
时,它会起作用

我错过什么了吗?这可能是回形针检查内容类型的错误吗?有什么方法可以看出回形针认为文件的内容类型是什么

Started POST "/mods" for 127.0.0.1 at 2014-08-02 11:28:56 +0200
Processing by ModsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"FhBvyd8jOapcjONk8kyOgGE/oOZPA+sDBJxr/w3zUG0=", "mod"=>{"title"=>"Girl Next Door", "release(1i)"=>"2014", "release(2i)"=>"8", "release(3i)"=>"2", "song"=>#<ActionDispatch::Http::UploadedFile:0x00000000e763c8 @tempfile=#<Tempfile:/tmp/RackMultipart20140802-1742-wujc7n>, @original_filename="Wiklund_-_Girl_next_door.xm", @content_type="audio/x-xm", @headers="Content-Disposition: form-data; name=\"mod[song]\"; filename=\"Wiklund_-_Girl_next_door.xm\"\r\nContent-Type: audio/x-xm\r\n">}, "commit"=>"Save"}
Command :: file -b --mime '/tmp/d437374435a48a211b1f7b9e585c4c2d20140802-1742-1259ddt.xm'
   (0.1ms)  begin transaction
Command :: file -b --mime '/tmp/d437374435a48a211b1f7b9e585c4c2d20140802-1742-1e5e5sn.xm'
于2014-08-02 11:28:56+0200为127.0.0.1发布了“/mods”
ModsController处理#创建为HTML
参数:{“utf8”=>“✓", "真实性令牌“=>”FHBYD8JOAPCJONK8KYOGGE/oOZPA+sDBJxr/w3zUG0=“,”mod“=>”{“标题”=>“隔壁女孩”,“发布(1i)”=>“2014”,“发布(2i)”=>“8”,“发布(3i)”=>“2”,“歌曲”=>,“提交”=>“保存”}
命令::file-b--mime'/tmp/d43734435a48a211b1f7b9e585c4c2d20140802-1742-1259ddt.xm'
(0.1ms)开始事务处理
命令::file-b--mime'/tmp/d43734435a48a211b1f7b9e585c4c2d20140802-1742-1e5e5sn.xm'

我认为内容类型验证应该如下所示:

validates_attachment :song, presence: true,
  content_type: { content_type: ["audio/x-mod"] },
  size: { in: 0..128.kilobytes }
validates_attachment_content_type : song, :content_type => /\Aaudio/


从日志
content\u type=“audio/x-xm”
,对于内容类型验证回形针使用regexp,您可以在中检查此项。谢谢,我完全忽略了日志中的部分。我假设内容类型必须是
audio/x-mod
,因为
file-b--mime类型就是这么说的。